PHP Array: Processing Array Use SPL



PHP Array Tips - Part 2: We have talked about array processing at here. At that post, we know there are 3 way processing array. Now, we see how to process array use Standard PHP Library (SPL).
<?php
$arr = array('mango',
             'banana',
			 'apple',
			 'rambutan',
			 'pineaple',
			 'strawbery');

$iterator = new ArrayIterator($arr);

$iterator->rewind();

while($iterator->valid()){
  echo $iterator->key() . " : " . $iterator->current() . " <br>";
  $iterator->next();
}

?>

Back to TOC Array Tips



Series this article:
PHP Array: Processing Array Use SPL
PHP Array: Processing Nested Array
PHP Array: Using SPL to Process Nested Array
PHP Array: Counting Number of Elements
PHP Array: Converting Strings to Arrays
PHP Array: Converting Arrays to Strings
PHP Array: Swapping Array keys and Values
PHP Array: Adding element to an Array
PHP Array: Taking an Element off the beginning of the array
PHP Array: Adding an Element to the Beginning of the Array
PHP Array: Taking an element off the end of the array
PHP Array: Adding or removing elements from the middle of an array
PHP Array: Extracting Contiguous Segments of an Array
PHP Array: Removing Duplicate Array Elements
PHP Array: Re-indexing Array
PHP Array: Randomizing Array
PHP Array: Searching Arrays
PHP Array: Searching Nested Array
PHP Array: Reversing Arrays
PHP Array: Filtering Array Elements
PHP Array: Sorting Arrays


Tag: array, spl Category: PHP Basic Post : March 26th 2008 Read: 4,532 Bookmark and Share

blog comments powered by Disqus