anujgarg Posted September 29, 2008 Share Posted September 29, 2008 I have a string looks like: 123, 234: 333, 444: 555, 666: 111, 222 I want to separate this string from each colon, like: 123, 234 333, 444 555, 666 111, 222 I could use split for the same purpose, but this string can have multiple colons ( as this is being generated dynamically. For this, I have to count total number of colons ( first, then to split. How can I do this? Or there is any other method to do it? TIA Link to comment https://forums.phpfreaks.com/topic/126235-split-string/ Share on other sites More sharing options...
Sulman Posted September 29, 2008 Share Posted September 29, 2008 You can use explode to do this: <?phph $your_string="123, 234: 333, 444: 555, 666: 111, 222"; $explodede_array=explode(",", $your_string); //$explodede_array[0] will hold 123. //$explodede_array[1] will hold 234:333. . . . etc <? Link to comment https://forums.phpfreaks.com/topic/126235-split-string/#findComment-652775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.