• How to use iterative function in PHP

    Using PHP, we can have iterative function like array_walk and we can use this function as following.

    array_walk — It’s a user function to every member of an array

    Syntax : bool array_walk ( array , $callback [, $userdata = NULL ] )
    Parameters :
    1. array : Input array.
    2. Callback : Here, array parameter’s value will be first, and the key/index second.

    Return Values : Returns TRUE or FALSE
    Example:

    1
    
     

    Output as follows:

    Before … :
    d. lemon
    a. orange
    b. banana
    c. apple
    … and after:
    d. fruit: lemon
    a. fruit: orange
    b. fruit: banana
    c. fruit: apple

    We can not ‘break’ (to use the terminology) from an array walk callback.

Comments on this post

Leave a Reply

  • Security Code :


    + 4 = six