[Solved] Arrays - functions and sorting in PHP

  

3
Topic starter

Can you please share the advanced functionality in PHP of the arrays and the associative arrays and their functions and sorting functions?

Please give some examples with code.

Thanks

1 Answer
2

Some commonly used:

array functions php

Click here to see all of them

Examples:

array_push($arr, variable) - push (add) one or more elements into the end of array:

$arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
array_push($arr, 11, 12, 13, 100);
 
echo implode(", ", $arr);
// $arr = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 100

array_pop($arr) - Pop (remove) the element of the end of the array:

$arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
array_pop($arr);
 
echo implode(", ", $arr);
// $arr = 1, 2, 3, 4, 5, 6, 7, 8, 9

 

Share: