A weak problem

Source: Internet
Author: User
A weak problem $ Foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese ");
$ Bar = each ($ foo );
Print_r ($ bar );
?>

Which one can parse it in detail? =-= I don't know the output result.


Reply to discussion (solution)

Php system functions have nothing to explain. just know how to use them.
Returns the key/value pair of the current pointer position in the array and moves the array pointer forward. The key-value pair is returned as an array of four units, with the key names 0, 1, key, and value. Unit 0 and key contain the key name of the array unit, and 1 and value contain data.

If the internal pointer crosses the end of the array, each () returns FALSE.

Is there a description in the manual? how can this problem be solved.

$ Foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese ");
Foreach ($ foo, $ key, $ value)
{
Echo "subscript". $ key. "value:". $ value;
}
// The following should output the first element
$ Bar = each ($ foo );
Print_r ($ bar );
?>

Php system functions have nothing to explain. just know how to use them.
Returns the key/value pair of the current pointer position in the array and moves the array pointer forward. The key-value pair is returned as an array of four units, with the key names 0, 1, key, and value. Unit 0 and key contain the key name of the array unit, and 1 and value contain data.

If the internal pointer crosses the end of the array, each () returns FALSE.



Why is the key name 0 and key secret? The key value is the same, and the key value is the same as the key value.

Php arrays have two manifestations:
One is a subscript array that uses numbers as the subscript for access
One is join array, also named join key access
Only one element of the same array can be used.

This is because the each function returns the array information in two forms for you to choose to use

Php arrays have two manifestations:
One is a subscript array that uses numbers as the subscript for access
One is join array, also named join key access
Only one element of the same array can be used.

This is because the each function returns the array information in two forms for you to choose to use



Key and 0 value and 1 are default values.

Yes
0 and 1, key and value




Yes
0 and 1, key and value


Thanks

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.