October 11

Useful PHP Arrays


Array is one of the most important  part in every programming languages. PHP provides a very strong set of arrays.

Below is the list of arrays:

Numerical Array: 

$myarray = array();
$myarray[0] = “data 1”;
$myarray[1] = “data 2”;
$myarray[3] = “data 3”;

Continue reading

Category: Arrays | LEAVE A COMMENT
September 18

Difference between array_merge and array_combine in php


Merge one or more arrays.

Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one.
If the input arrays have the same string keys, then the later value for that key will overwrite the previous one or if the arrays contain numeric keys, then the later value will not overwrite the original value and will be appended.

Values in the input array with numeric keys will be renumbered with increment keys starting from zero in the result array.

Kindly have a look on example given below

$array1 = array(“color” => “green”, 2, 4);
$array2 = array(“a”, “b”, “color” => “blue”, “shape” => “sqaure”, 4);
$result = array_merge($array1, $array2);


Output will:

Continue reading

Category: Arrays | LEAVE A COMMENT