PHP current Next reset function _php Tutorial

Source: Internet
Author: User
$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
}


http://www.bkjia.com/PHPjc/445391.html www.bkjia.com true http://www.bkjia.com/PHPjc/445391.html techarticle $array =array (step one,step two,step three,step four);//defines an array of echo current ($array). n;//returns the first element of the array next ($array); The array pointer moves back one next ($array) ...

  • Related Article

    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.