array_push in php
$myArr = [1, 2, 3, 4];
array_push($myArr, 5, 8);
print_r($myArr); // [1, 2, 3, 4, 5, 8]
$myArr[] = -1;
print_r($myArr); // [1, 2, 3, 4, 5, 8, -1]<?php
$cesta = array("laranja", "morango");
array_push($cesta, "melancia", "batata");
print_r($cesta);
?>
<?php
$z = ['me','you', 'he'];
array_push($z, 'she', 'it');
print_r($z);
?><?php
$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
/*
Array
(
[color] => green
[0] => 2
[1] => 4
[2] => a
[3] => b
[shape] => trapezoid
[4] => 4
)
*/
?><?php
// Insert "blue" and "yellow" to the end of an array:
$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
?>$myArray = array("name" => "my name");
echo json_encode($myArray);
Also in PHP:
- current datetime php function
- detect right click js
- Undefined offset: 0 at laravel\framework\src\Illuminate\Routing\Router.php
- create table modal and seeder at once in laravel
- create seeder laravel
- 'laravel collective"Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
- composer global require laravel/installer version 5.61
- check if key is already exist in an associative array php
- count php string
- * in array key php
- data type php varchar
- Allowed memory size of 134217728 bytes exhausted (tried to allocate 157 bytes) in C:\wamp64\scripts\refresh.php on line 2263
- $e = array("red", "green", "blue"); echo intval($e) . "<br>";
- developer polyglots
- A random character from a string of characters:
- Generate Laravel Migrations from an existing database
- What is a Regular Expression in php
- check composer version in cmd
- array has key php
- create a class in php
- add one day in php
- create model controller migration factory laravel in one command
- content type php header
- 1054 unknown column 'updated_at' in 'field list' laravel