Edited, memorised or added to reading queue

on 29-May-2015 (Fri)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Article 150891762

php 6

6.4 Looping Through Arrays with foreach As you just saw, it's easy to use each() in combination with while to loop through all the elements of an array. In fact, there's an even easier way: you can use PHP's foreach statement. foreach is a special kind of looping statement that works only on arrays (and objects). You can use it in two ways. You can either retrieve just the value of each element, or you can retrieve the element's key and value. Using foreach to Loop Through Values The simplest way to use foreach is to retrieve each element's value, as follows: foreach ( $array as $value ) { // (do something with $value here) } // (rest of script here) As you might imagine, the foreach loop continues to iterate until it has retrieved all the values in the array, from the first element to the last. On each pass through the loop, the $value variable gets set to the value of the current element. You can then do whateve



Flashcard 150892486

Question
sort() and rsort()
Answer
[default - edit me]

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
php 6
on, then sort the array by number of purchases to see who your most loyal customers are. When it comes to sorting arrays, PHP provides no less than twelve functions that you can use to sort an array. The more common ones are: <span>sort() and rsort() — For sorting indexed arrays asort() and arsort() — For sorting associative arrays ksort() and krsort() — For sorting associative arrays by key rather than by value array_multisort







Flashcard 150892490

Question
sort() and rsort()
Answer
for sorting indexed arrays

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
php 6
on, then sort the array by number of purchases to see who your most loyal customers are. When it comes to sorting arrays, PHP provides no less than twelve functions that you can use to sort an array. The more common ones are: <span>sort() and rsort() — For sorting indexed arrays asort() and arsort() — For sorting associative arrays ksort() and krsort() — For sorting associative arrays by key rather than by value array_multisort







indofloopingstatementthatworksonlyonarray
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

pdf

cannot see any pdfs




lkindofloopingstatementthatworksonly
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

pdf

cannot see any pdfs




learnedaboutvariablesinPHP;inparticular,you
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

pdf

cannot see any pdfs




tvariablesinPHP;inparticular,youlearnedthat
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 150892672

Question
statement that works
Answer
[default - edit me]

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
php 6
As you just saw, it's easy to use each() in combination with while to loop through all the elements of an array. In fact, there's an even easier way: you can use PHP's foreach statement. foreach is a special kind of looping <span>statement that works only on arrays (and objects). You can use it in two ways. You can either retrieve just the value of each element, or you can retrieve the element's key and value. &#1