How to echo out all elements of php array at once?
Asked Answered
L

1

8

hi friends I have a php array for eg.

$mob_numbers= array(12345674, 12345675, 12345676,12345677);

I want to eacho out all of them at once so that it appears

12345674,12345675,12345676,12345677 (with comma) .

How do i do it ? I tried array explode, didn't work. Pls help

Lunar answered 13/9, 2010 at 7:44 Comment(0)
S
19

Just use implode function as:

echo implode(',',$mob_numbers);

explode is used to split a string to get an array

implode does the opposite of joining the array elements to get a string.

Sanmicheli answered 13/9, 2010 at 7:46 Comment(1)
... also known as join in other languages (in fact, PHP also has a join() alias for implode())Unparalleled

© 2022 - 2024 — McMap. All rights reserved.