Author Topic: [PHP] Array  (Read 1126 times)

0 Members and 1 Guest are viewing this topic.

Offline Code.Illusionist

  • Royal Highness
  • ****
  • Posts: 687
  • Cookies: 39
  • Compile or die trying
    • View Profile
[PHP] Array
« on: 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?
Vae Victis - suffering to the conquered

Offline ca0s

  • VIP
  • Sir
  • *
  • Posts: 432
  • Cookies: 53
    • View Profile
    • ka0labs #
Re: [PHP] Array
« Reply #1 on: July 08, 2013, 04:21:15 pm »
Code: (php) [Select]
<?php
$s 
"7!3!9!05!2401!64!05!11!64!4!343!2!11!9!04";
$a explode("!"$s);
print_r($a);
?>

Code: [Select]
http://php.net/manual/es/function.explode.php

Offline erc

  • NULL
  • Posts: 3
  • Cookies: 0
  • Anarchism!
    • View Profile
Re: [PHP] Array
« Reply #2 on: August 22, 2013, 11:17:19 pm »
Code: [Select]
<?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] . "&emsp;";
}


?>