In this tutorial learn how to add value to an array or Append a value to an array in php using array_push() method
TUTORIAL
OUTPUT
TUTORIAL
<?php $array = Array ( '3' => 10, '2' => 2, '5' => 'Nakiya', ); /** * Append a value to an array. */ function appendelement($array, $value) { array_push($array, $value); return $array; } var_dump(appendelement($array,100));
array(4) { [3]=> int(10) [2]=> int(2) [5]=> string(6) "Nakiya" [6]=> int(100) }
No comments:
Post a Comment