EvilZone
Programming and Scripting => Web Oriented Coding => : Code.Illusionist July 08, 2013, 04:13:09 PM
-
Hello again. Today I have problem to break string and take those peaces into array. For example I have this string: 7!3!9!05!2401!64!05!11!64!4!343!2!11!9!04 .
Now, I'd like to take all the numbers separated by sign ! . So my new array contain:
7 , 3, 9, 05, 2401 , 64, 05, 11, 64, 5, 343, 2 ,11, 9, 04 .
How can I do such a thing?
-
<?php
$s = "7!3!9!05!2401!64!05!11!64!4!343!2!11!9!04";
$a = explode("!", $s);
print_r($a);
?>
http://php.net/manual/es/function.explode.php
-
<?php
$str = "7!3!9!05!2401!64!05!11!64!4!343!2!11!9!04";
$newstr = explode('!',$str);
for($i = 0; $i < count($newstr ); $i++)
{
echo $d[$i] . " ";
}
?>