Jump to content

Array in semicolon and comma


abdul_zu

Recommended Posts

Hi All,

 

I have the following string. i need to make two loop one will run for each ; and another will run under this first loop but with comma.

 

$val = "
00->,01,011->,00->5554,8889,011->5554,9972,011->9972;00->,01,011->;00->,01,011->,00->5554,8889,011->5554,9972,011->9972;00->,01,011->";

 

Could you please help me to separating this string?

 

Regards,

Link to comment
https://forums.phpfreaks.com/topic/179370-array-in-semicolon-and-comma/
Share on other sites

Store the values within two separate arrays using the explode() function.  After that you just run each through a loop statement.

 

$loop1 = explode(";", $string);

$loop2 = explode(",", $string);

 

foreach($loop1 as $loop)

{

//do something

}

 

foreach($loop2 as $loop)

{

//do something else

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.