add array to array 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
$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
)
*/
?>$myArray = array("name" => "my name");
echo json_encode($myArray);array_push($cart, 13);
$cart = array();
$cart[] = 13;
$cart[] = 14;
// etc
//Above is correct. but below one is for further understanding
$cart = array();
for($i=0;$i<=5;$i++){
$cart[] = $i;
}
echo "<pre>";
print_r($cart);
echo "</pre>";
Also in PHP:
- exceptionhandling php
- add on day to date php
- apt install php 7.4
- PHP code for profile page add, edit, delete member?
- disable all auth route laravel
- date format in php for AM PM
- confirm password validation in laravel
- create model, controller and migration in single command laravel
- current timestamp with sec in php to strstring
- check if an array index exists php
- clean cache laravel
- composer require rtconner/laravel-tagging
- "data:text/vcard;
- enc php code base64
- check type of variable laravel
- can you have more than one constructor in class php
- date format ph
- built in functions in php for uppercase
- Allowed memory size of 134217728 bytes exhausted laravel
- convert text toupper case php
- check if part of string php
- cache clear in laravel for serve
- ci4 throw new exception
- catch exception php of spetie