Answers for "array php add variable"

PHP
6

add item to array in php

<?php

$a=array("red","green");

array_push($a,"blue","yellow");

print_r($a);
?>
Posted by: Guest on May-25-2020
3

add object in array php

$myArray = array("name" => "my name");
echo json_encode($myArray);
Posted by: Guest on April-27-2020

Browse Popular Code Answers by Language