Answers for "php move array element to end"

PHP
2

php array move first element to last

$array = array("PHP", "JS", "JAVA");
$first_element = array_shift($array);
$array[count($array) + 1] = $first_element;
print_r($array);
Posted by: Guest on June-09-2021
0

php move element to beginning of array

$array = array("JS", "JAVA");
array_unshift($array, "PHP");
print_r($array);
// Add More Than One Element
$array1 = array("JS", "JAVA");
array_unshift($array1, "PHP", "CSS", "HTML");
print_r($array1); // => { PHP CSS HTML JS JAVA }
Posted by: Guest on June-09-2021

Code answers related to "php move array element to end"

Browse Popular Code Answers by Language