Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Array element navigation

Tue Oct 28, 2008 1:05 am

Code:

<?
$major_city_info
= array();
$major_city_info[0] = 'A';
$major_city_info['A'] = 'B';
$major_city_info[1] = 'C';
$major_city_info['C'] = 'D';
$major_city_info[2] = 'E';
$major_city_info['E'] = 'F';

function
print_all_array_backwards($city_array)
{  
  
$current_item = end($city_array); //fast-forward to last
  
  
if ($current_item)
    print(
"$current_item<BR>");
  else
    print(
"There's nothing to print");
  while(
$current_item = prev($city_array))
    print(
"$current_item<BR>");
}
print_all_array_backwards($major_city_info);

?>




Post a reply
  Related Posts  to : Array element navigation
 Pop the element off the end of array     -  
 UnSet array element     -  
 access element in array C++     -  
 find the largest element stored in the array     -  
 find out the number of elements in an array of 8-bit element     -  
 navigation menu using JQuery     -  
 Array difference for associate array     -  
 Usage of big element tag.     -  
 print element in 2d matrix     -  
 lesson1 : <schema> Element     -  

Topic Tags

PHP Arrays