php

Useful Array Functions in PHP

Dear readers, I present some of the most useful functions to operate on arrays.

Please, comment :)

Finding all keys of an array

<?php
$myArray=array(1=>"em"),6=>"value";

array_keys($myArray); //returns array(1,6)
?>

Running through all values of an array

<?php
$myFriends=array('Mike','Jake','Helen');

foreach($myFriends as $friend){
  echo $friend . ' is my friend <br>';
}
?>

Some of the more obvious ones.

Checking if an array is empty

<?php
$Arr = array('value');