Php method for getting the first array cell value of an array _php tutorial

Source: Internet
Author: User
Tags array to string javascript array
This article mainly explains how to get the value of the first array cell in PHP. In PHP's built-in function, the function that gets the value of the array element has the following functions: Reset next Current prev end.

Reset (PHP 3, PHP 4, PHP 5)

function definition mixed reset (array &array)

Function: The function returns the internal pointer of the array back to the first cell and returns the value of the first array cell, FALSE if the array is empty. For example:

 

Next (PHP 3, PHP 4, PHP 5)

function definition mixed next (array &array)

Function: Returns the value of the next cell pointed to by the array's internal pointer, or FALSE if there are no more cells. For example:

  

Warning: If the array contains empty cells, or if the value of the cell is 0, the function will also return FALSE if it encounters these cells. To properly traverse an array that may contain empty cells or a cell value of 0, see the each () function.

Current (PHP 3, PHP 4, PHP 5)

function definition mixed current (array &array)

Function: Returns the value of the array cell that is currently pointed to by the internal pointer, and does not move the pointer. Initially points to the first cell inserted into the array. If the internal pointer points beyond the end of the cell list, current () returns FALSE.

Warning: If the array contains empty cells (0 or "", an empty string), this function also returns FALSE when it encounters this unit. This makes it impossible to use current () to determine whether the end of this array list is reached. To properly traverse an array that may contain empty cells, use the each () function.

Next () and current () behave similarly, with only a little difference, moving the inner pointer forward one bit before the return value. This means that it returns the value of the next array cell and moves the array pointer forward one bit. If the result of moving the pointer is beyond the end of the array cell, then next () returns FALSE.

The following are examples of the use of related functions:

   

Articles you may be interested in

    • PHP uses Array_flip to implement array key-value Exchange to remove array duplicate values
    • A detailed description of the JavaScript array (how arrays are declared and how they are calculated)
    • Summary of methods for removing duplicate values in PHP two-dimensional arrays
    • How PHP removes the first and last elements of an array
    • JS array to string, JS string to array method summary
    • Introduction to the set, intersection, and difference functions of arrays in PHP
    • PHP generates consecutive numbers (Letters) array function range () analysis, PHP lottery program function
    • PHP clears null elements in array

http://www.bkjia.com/PHPjc/764095.html www.bkjia.com true http://www.bkjia.com/PHPjc/764095.html techarticle This article mainly explains how to get the value of the first array cell in PHP. In PHP's built-in function, the function that gets the value of the array element is mainly reset ...

  • 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.