array_push
$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
$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
)
*/
?>$array[$key] = $value;
// or
$array[] = $value;
// or
array_push($array, [ mixed $... ]);<?php
$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
?>$a = array('foo' => 'bar'); // when you create
$a['Title'] = 'blah'; // later
Also in PHP:
- date now php
- current date time php
- DateTime TO UNIx timestamp PHP
- enable php erros
- check if includes numbers php
- Illuminate\Http\Request vs \Illuminate\Support\Facades\Request
- clear cache in chrome
- add class to body class wordpress
- error reporting php
- creat folder in php
- No match for argument: phpmyadmin yum
- codeigniter device
- create timestamp from string php
- ->sale_price
- comparacion cache laravel
- count number of characters in a string in php
- create project with laravel
- find position of character in string php
- <?php echo do_shortcode(' '); ?> with variable
- calculate string length php
- check if string contains specific string
- 1071 Specified key was too long;
- 3 letter month abbreviations in php date format
- don't show warnings php