本教程主要是用到了 array_slice array_search array_shift array_unique array_unshift这几个函数的应用实例了.
- */
- $input=array("a","b","c","d","e");
- $output=array_slice($input,2);
- $output=array_slice($input,-2,1);
- $output=array_slice($input,0,3);
- print_r(array_slice($input,2,-1));
- print_r(array_slice($input,2,-1,true));
-
- $array=array('blue','red','green','red');
- $key=array_search('green',$array);
- echo $key;
- echo "<br>";
- $key=array_search('red',$array);
- echo $key;
-
- $array=array("orange","banana","apple","raspberry");
- $result=array_shift($array);
- print_r($result);
- echo "<br>";
- print_r($array);
-
- $input=array("a"=>"green","red","b"=>"green","blue","red");
- $result=array_unique($input);
- print_r($result);
-
- $array=array("orange","banana");
- $result=array_unshift($array,"apple","raspberry");
- print_r($result);
- echo "<br>";
- print_r($array);