Horje
php append to array Code Example
php append to array
$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 add 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 )
Source: www.php.net
php add item to array
<?php
  $z = ['me','you', 'he'];
  array_push($z, 'she', 'it');
  print_r($z);
?>
array_push in php
<?php
// Insert "blue" and "yellow" to the end of an array:


$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
?>
add item to array in php
<?php

$a=array("red","green");

array_push($a,"blue","yellow");

print_r($a);
?>
php add element to array

<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
?>

Source: www.php.net




13

Related
php check if string contains word Code Example php check if string contains word Code Example
laravel clear cache Code Example laravel clear cache Code Example
php string replace Code Example php string replace Code Example
php length of array Code Example php length of array Code Example
array count items Code Example array count items Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11