Mega Code Archive

 
Categories / Php / Data Type
 

Using the isset() function to see whether an array element is defined for a given index

<?php  $array = array('a' => 'R', 'b' => 2, c => '2');  print "<p>Using for:</p>\n<p>";  $limit = count($array);  for($i = 0; $i < $limit; $i++)      if( isset($array[$i]) )          printf("&middot; %s,", $array[$i]);  ?>