Example of current, next, and reset function usage in php, currentreset_PHP tutorial

Source: Internet
Author: User
Example of current, next, and reset function usage in php, currentreset. Current, next, and reset function usage examples in php. currentreset this article describes the usage of current, next, and reset functions in php. Share it with you for your reference. The code is as follows: current, next, and reset function usage instances in php, currentreset

This article describes the usage of current, next, and reset functions in php. Share it with you for your reference.

The code is as follows:

The code is as follows:

$ Array = array ('step one', 'step two', 'step three ', 'step four'); // defines an array
Echo current ($ array )."
N "; // returns the first element of the array.
Next ($ array); // The array pointer moves one bit behind
Next ($ array); // The array pointer moves one bit behind
Echo current ($ array )."
N "; // returns the current element of the array, the third value
Reset ($ array); // pointer to the first value of the array
Echo current ($ array )."
N "; // returns the first value of the array.

//

$ Info = array ('red', 'blue', 'green'); // defines an array.
While ($ result = current ($ info ))
{
Echo $ result;
Echo"
";
Next ($ info );
}

//

$ Array = array (
'Fruit1' => 'apple ',
'Fruit2' => 'Orange ',
'Fruit3' => 'grape ',
'Fruit4' => 'apple ',
'Fruit5' => 'apple'); // defines an array.
While ($ fruit_name = current ($ array) // Obtain the current value of the array cyclically
{
If ($ fruit_name = 'apple') // if the current value is apple
{
Echo key ($ array ).'
'; // Key name of the output current value
}
Next ($ array); // Move the array pointer down one step
}

I hope this article will help you with PHP programming.

Examples in this article describes the usage of current, next, and reset functions in php. Share it with you for your reference. The code is as follows :...

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.