add values to array dynamically php

Solutions on MaxInterview for add values to array dynamically php by the best coders in the world

showing results for - "add values to array dynamically php"
Lisa
10 Jun 2018
1There are quite a few ways to work with dynamic arrays in PHP. Initialise an array:
2
3$array = array();
4Add to an array:
5
6$array[] = "item"; // for your $arr1 
7$array[$key] = "item"; // for your $arr2
8array_push($array, "item", "another item");
9Remove from an array:
10
11$item = array_pop($array);
12$item = array_shift($array);
13unset($array[$key]);
14There are plenty more ways, these are just some examples.