Pages

Showing posts with label array. Show all posts
Showing posts with label array. Show all posts

PHP : Multi-dimensional array sort by sub array value

Multi-dimensional array - how to sort array by sub array value using  array_multisort() and array_map() function.

You can sort array ascending(SORT_ASC) or Descending(SORT_DESC) order with Sub Array value.

PHP: Delete an element from an array

PHP: Delete an element from an array 


 $array = array(0 => "x", 1 => "y", 2 => "z");
    unset($array[0]);
print_r($array);

//Output: Array ( [1] => y [2] => z )

What does the => operator mean in the following code?


What does the => operator mean in the following code?

$foo = array('car', 'truck', 'van', 'bike', 'rickshaw');
foreach ($foo as $i => $type) {
    echo "{$i}: {$type}\n";
}

//Output:    0: car 1: truck 2: van 3: bike 4: rickshaw

Popular Posts