Today's Lesson: PHP 3-Day Foundation Consolidation video Tutorial "Yan 18"
1. Array cursor operation
/*current (), Next ();p rev (), End (), *///the value of the array cell to which the current cursor is pointing $arr = Array (' A ', ' B ', ' C '), the Echo present ($arr); next ($arr); echo Current ($arr);//move the array cursor back to end ($arr), Echo current ($arr),//move the array cursor to the last prev ($arr), Echo current ($arr);//move the array cursor forward reset ($ ARR), Echo current ($arr),//Reset the array to echo "<br/>", while ($v = current ($arr)) {echo $v, ' <br/> '; next ($arr);} In this case, you can use each function to process $arr = Array (1,2,3,false,4,5,6), while ($v = ($arr)) {echo $v, ' <br/> '; next ($arr);} echo "<br/>"; $arr = Array (1,2,3,false,4,5,6); echo each ($arr), ' <br/> ';
2. Common functions of arrays
Judge the general array $arr = Array (' a ' = = ' ZK ', ' b ' = ' en ', ' C ' =>null), if (Isset ($arr [' a '])) {echo ' a exists ';} Else{echo ' A does not exist ';} echo "<br/>";//half-empty array if (array_key_exists (' C ', $arr)) {echo ' C exists ';} Else{echo ' C does not exist ';} echo "<br/>"; if (In_array (' zh ', $arr)) {echo "zh exists";}
3. Breeding of small sheep in array case
echo "<br/>"; $arr = Array (' A ', ' B ', ' C ', ' d '), Echo array_push ($arr, ' e '), ' <br/> ';//array tail append unit, and returns the array length after the operation of Echo Array_pop ($arr), ' <br/> ';//eject the tail as echo array_unshift ($arr, ' z '), ' <br/> ';p rint_r ($arr); echo Array_shift ($arr), ' <br/> ';///Pop-up Print_r ($arr); echo "<br/>";//a sheep, a sheep in the second year, a sheep in the fourth year, five years to die, How many sheep are left after 20 years? $yang = Array (1,0,0,0,0), for ($y = 1; $y <=, $y + +) {$tmp = $yang [1] + $yang [3];array_unshift ($yang, $tmp); Array_pop ($ya NG);} echo array_sum ($yang);p rint_r ($yang); echo "<br/>";/*m only monkeys to choose the King, the election method is as follows: All monkeys according to the 1,2......N number in a circle, starting from the first sequence 1,2......m, usually reported in the exit ring of M, so loop off until only a monkey in the circle, this monkey is king. * * After the class, the math is too bad, I don't know, I'll say later
4. Super Global variables
This is it, rest!
This article from "A Big big waste fish" blog, declined reprint!
Abandoned fish--how long does PHP take to get from getting started to giving up? 11