Examples of current, next, and reset function usages in PHP, Currentreset
This article describes the usage of current, next, and reset functions in PHP. Share to everyone for your reference.
The specific code is as follows:
Copy the code as follows: $array =array (' Step One ', ' Step ', ' step three ', ' step Four '); Define an array
Echo current ($array). "
n "; Returns the first element of an array
Next ($array); The array pointer moves back one
Next ($array); The array pointer moves back one
Echo current ($array). "
n "; Returns the current element of the array, the third value
Reset ($array); The pointer points to the first value of the array
Echo current ($array). "
n "; Returns the first value of an array
//
$info =array (' Red ', ' blue ', ' green '); Defining arrays
while ($result =current ($info))
{
echo $result;
echo "
";
Next ($info);
}
//
$array =array (
' Fruit1 ' = ' apple ',
' Fruit2 ' = ' orange ',
' fruit3 ' = ' grape ',
' Fruit4 ' = ' apple ',
' Fruit5 ' = ' apple '); Defining arrays
while ($fruit _name=current ($array))//loop Gets the current value of the array
{
if ($fruit _name== ' apple ')//If the current value is Apple
{
echo Key ($array). '
'; The key name of the output current value
}
Next ($array); Move the array pointer down one step
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/912675.html www.bkjia.com true http://www.bkjia.com/PHPjc/912675.html techarticle Examples of current, next, and reset functions in PHP, currentreset the current, next, and reset function usages in PHP. Share to everyone for your reference. The specific code is as follows: ...