PHP Array empurre com a chave
<?php
$a=array("a"=>"red","b"=>"green");
array_push($a,"blue","yellow");
print_r($a);
?>
Darkvent
<?php
$a=array("a"=>"red","b"=>"green");
array_push($a,"blue","yellow");
print_r($a);
?>
use Illuminate\Support\Arr;
$array = Arr::add(['name' => 'Desk'], 'price', 100);
// or this one:
$array = Arr::add($array, 'price', 100);
// Error : "array_push() expects parameter 1 to be array, null given"
// Don't array_push($array,$arrayValueToPush);
// Set the array value.
$array["arrayKey"] = $arrayValue;
//----------------------------------------
$newArray = [];
foreach ($arrayItems as $key => $arrayItem) {
$newArray[$key]["arrayItemKey1"] = $arrayItem["arrayItemKey1FromArrayItem"];
$newArray[$key]["arrayItemKey2"] = $arrayItem["arrayItemKey2FromArrayItem"];
}
// laravel
use Illuminate\Support\Arr;
$array = Arr::add(['name' => 'Desk'], 'price', 100);
// or this one:
$array = Arr::add($array, 'price', 100);
<?php
$image[0] = $image[0].','.$filename;
?>