$arr=array("1","3","4"); echo $arr[1]; through this we can print only one value of the array(wrt index).but,is there any way to print entire array at a time?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

$arr=array("1","3","4"); echo $arr[1]; through this we can print only one value of the array(wrt index).but,is there any way to print entire array at a time??

14th Jan 2016, 3:51 AM
krrish...
3 Answers
0
you can use array_values function that returns all the values from the ARRAY and indexes the array NUMERICALLY... <?php $array = array("size" => "XL" ,"color" => "gold"); print_r(array_values($array)); ?> OUTPUT IS: Array ( [0] => XL [1] => gold )
16th Jan 2016, 8:32 AM
Masoud Farmani
Masoud Farmani - avatar
0
use the foreach loop eg) <?php $arr=array("John","James","Peter"); foreach($arr as $value) { echo $value."<br>"; } ?>
28th Oct 2016, 9:43 PM
David
- 1
Just try echo$arr
17th Jun 2016, 6:19 AM
Vipul Singh
Vipul Singh - avatar