Position of PHP array elements

Source: Internet
Author: User
The position of the element in {code...} $ array_one is known, for example, the position of & #039; two & #039; is 2. But in $ array_two, is the position of & #039; two and two & #039; still 2? Obviously not. What if I want to change the elements of positions 1 and 3? {Code ...}
$array_one = ['one','two','three'];$array_two = ['one'=>'one,one','two'=>'two,two','three'=>'three,three'];

$array_oneThe position of the element in is known. For example, the position of 'two' is 2.
However$array_twoIs the position of 'two, two' in 2?

Obviously not. What if I want to change the elements of positions 1 and 3?

$array_two = ['three'=>'three,three','two'=>'two,two','one'=>'one,one'];

Reply content:
$array_one = ['one','two','three'];$array_two = ['one'=>'one,one','two'=>'two,two','three'=>'three,three'];

$array_oneThe position of the element in is known. For example, the position of 'two' is 2.
However$array_twoIs the position of 'two, two' in 2?

Obviously not. What if I want to change the elements of positions 1 and 3?

$array_two = ['three'=>'three,three','two'=>'two,two','one'=>'one,one'];

Location?
It should be a subscript, And the subscript of two should be 1
The associated array of array_two is accessed with the key!

$ Array_two = array_reverse ($ array_two );

For more information about the three elements, see @ Mu.
You can also consider array_slice and add the 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.