ltbaggz Posted January 14, 2007 Share Posted January 14, 2007 i am trying to divide up a string using the explode function and i am having soem problems. the string is created like so:example2, 3:35&example1, 0:10&what i want to get out of it is array1[0] = example2array1[1] = example1array2[0] = 3:35array2[1] = 0:10the string can be any amount of elements long.if any one has a quick answer i would appreciate it, im going to keep working on it now.thanksDrew Link to comment https://forums.phpfreaks.com/topic/34131-help-with-explode-function/ Share on other sites More sharing options...
GingerRobot Posted January 14, 2007 Share Posted January 14, 2007 Try this:[code]<?php$str = "example2, 3:35&example1, 0:10";$lines = explode("&",$str);$array1 = array();$array2 = array();foreach($lines as $lines){ $parts = explode(",",$lines); $array1[] = $parts[0]; $array2[] = trim($parts[1]);}print_r($array1);print_r($array2);?>[/code]Outputs this:Array ( [0] => example2 [1] => example1 ) Array ( [0] => 3:35 [1] => 0:10 ) Link to comment https://forums.phpfreaks.com/topic/34131-help-with-explode-function/#findComment-160551 Share on other sites More sharing options...
ltbaggz Posted January 14, 2007 Author Share Posted January 14, 2007 sweet, thanks a lot for the help, i would have been playing with it for while. Link to comment https://forums.phpfreaks.com/topic/34131-help-with-explode-function/#findComment-160554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.