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 );

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.