Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel add item to array

$fruits = ["apple", "banana"];
// array_push() function inserts one or more elements to the end of an array
array_push($fruits, "orange");

// If you use array_push() to add one element to the array, it's better to use
// $fruits[] = because in that way there is no overhead of calling a function.
$fruits[] = "orange";

// output: Array ( [0] => apple [1] => banana [2] => orange )
Comment

insert value to elements of array laravel

foreach ($ids as $id) {
    $users[] = [
        'id' => $id,
        'status' => flase
    ];
}
User::insert($users);
Comment

laravel insert array

$projects = [
    [
        "name"        => "project-one",
        "description" => "description",
    ],
    [
        "name"        => "project-two",
        "description" => "description",
    ],
];
Project::insert($projects);
Comment

PREVIOUS NEXT
Code Example
Php :: php is int 
Php :: laravel migration remove nullable 
Php :: wordpress get user data from email 
Php :: laravel return view with multiple variable 
Php :: form validation for file type in codeigniter 
Php :: laravel check if item is in collection 
Php :: php location header 
Php :: php check if a url exists 
Php :: php artisan queue table 
Php :: laravel pagination with query string, laravel pagination with string 
Php :: get_categories not__in 
Php :: how to log object laravel logger 
Php :: grouping route in laravel 
Php :: type hidden value put laravel 
Php :: php xml string 
Php :: how to add custom field in comment form in wordpress 
Php :: post php 
Php :: php multi condition if 
Php :: pretty json php 
Php :: drop column table in migration if exist in laravel 
Php :: how to link image in laravel 
Php :: php call class method dynamically 
Php :: php sort array by value 
Php :: laravel get id from insert 
Php :: php sodium extension xampp 
Php :: laravel use global variable in model 
Php :: phpmyadmin centos 8 
Php :: how to read sqlite file in php 
Php :: wordpress get plugin list 
Php :: php check if link exists 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =