What array_walk,array_slice function does
array_walk function will run each array element inside a function see the below examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function testarraywalk($value,$key) { echo $value; echo $key; echo "<br>"; } $myArray=array("0"=>"vasanthan","1"=>"mydoubts.in","2"=>"wordsgallery.com"); array_walk($myArray,"testarraywalk"); //output //vasanthan0 //mydoubts.in1 //wordsgallery.com2 |
array_slice() function will slice the array from one element to other for example
1 2 3 4 5 6 7 8 9 10 |
$myArray=array("vasanthan","mydoubts.in","wordsgallery.com"); print_r(array_slice($myArray,1,2,true)); echo "<br>"; print_r(array_slice($myArray,1,2,false)); // output Array ( [1] => mydoubts.in [2] => wordsgallery.com ) Array ( [0] => mydoubts.in [1] => wordsgallery.com ) ?> |