Php array deletes the mobile value operation instance.

Source: Internet
Author: User



*/
$ Input = array ("a", "B", "c", "d", "e"); // defines the original array
$ Output = array_slice ($ input, 2); // return "c", "d", and "e"
$ Output = array_slice ($ input,-2, 1); // return "d"
$ Output = array_slice ($ input,); // return "a", "B", and, "c"
Print_r (array_slice ($ input, 2,-1); // return c, d without retaining the key name
Print_r (array_slice ($ input, 2,-1, true); // returns the reserved key names of c and d.


//

$ Array = array ('blue', 'red', 'green', 'red'); // defines the original array
$ Key = array_search ('green', $ array); // search for green and return 2;
Echo $ key;
Echo "<br> ";
$ Key = array_search ('red', $ array); // search for red to return key 1 of the first red
Echo $ key;

//
$ Array = array ("orange", "banana", "apple", "rasp tutorial berry"); // defines the initial array
$ Result = array_shift ($ array); // remove
Print_r ($ result); // display the pop-up element
Echo "<br> ";
Print_r ($ array );

//
$ Input = array ("a" => "green", "red", "B" => "green", "blue", "red "); // define the original array
$ Result = array_unique ($ input); // perform the remove operation.
Print_r ($ result );

//
$ Array = array ("orange", "banana"); // defines the original array
$ Result = array_unshift ($ array, "apple", "raspberry"); // execute the insert operation.
Print_r ($ result); // display the result
Echo "<br> ";
Print_r ($ array );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.