I have this as result from MySQL
(stored as $result
)
+-------------------------------------------------------------------------+
| CONCAT_WS('::', p.isMobile, p.contact_phone_id, p.contact_phone_number) |
+-------------------------------------------------------------------------+
| 0::1::123 |
| 1::2::456 |
| 0::3::789 |
| 1::4::987 |
| 0::5::654 |
| 0::6::321 |
| 1::7::123 |
| 1::11::456 |
+-------------------------------------------------------------------------+
Then in a while loop I use explode()
for each row like: explode('::', $result)
. How can I use foreach()
to output data like this (first three rows in while
iteration as example):
Row 1: The first column is 0, the second column is 1, the third column is 123
Row 2: The first column is 1, the second column is 2, the third column is 456
Row 3: The first column is 0, the second column is 3, the third column is 789