Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 602
ktm Avatar asked Sep 13 '10 07:09

ktm


People also ask

How do I echo an entire array?

To echo an array, use the format echo ${Array[0]}. Array is your array name, and 0 is the index or the key if you are echoing an associative array. You can also use @ or * symbols instead of an index to print the entire array.


1 Answers

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.

like image 87
codaddict Avatar answered Sep 20 '22 15:09

codaddict