Hello, I have this string from db: $str = "1:78 78 12345, 2:678 77 1234567899, 1:44 4 123456789"; The first is the type of phone - 1 or 2, after : should phone - 1: 2: 1: 1: . All separated by commas. How can I split this string so it foreach it. After each comma should type and next is phone. Thanks!
not sure if I understood correctly. try this $str = "1:78 78 12345, 2:678 77 1234567899, 1:44 4 123456789"; $str_ar = explode(',',$str); foreach ($str_ar as $item ) { $parts = explode (':',$item); echo 'part 1: '.$parts[0].'<br />; echo 'part 2: '.$parts[1].'<br /><br /><br />'; } PHP: