abdul_zu Posted October 28, 2009 Share Posted October 28, 2009 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 More sharing options...
SchweppesAle Posted October 28, 2009 Share Posted October 28, 2009 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 } Link to comment https://forums.phpfreaks.com/topic/179370-array-in-semicolon-and-comma/#findComment-946440 Share on other sites More sharing options...
cags Posted October 28, 2009 Share Posted October 28, 2009 Not sure I understand you, sounds abit like your after something along these lines... $arr1 = explode(";", $val); foreach($arr1 as $k=>$a) { $arr1[$k] = explode(",", $a); } echo '<pre>'; print_r($arr1); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/179370-array-in-semicolon-and-comma/#findComment-946442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.