开发者

Getting values from a single array [duplicate]

开发者 https://www.devze.com 2023-03-08 11:06 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to find the value from this array in php?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to find the value from this array in php?

hello coders.I have an array like this

Array
(
    [0] => Array
        (
            [0] => admin/login
            [1] => LoginHandler
            [2] => index
        )

    [1] => Array
        (
            [0] => post
            [1] => PostHandler
            [2] => index
        )

    [2] => Array
        (
            [0] => post/create
            [1] => postHandler
            [2] => create
        )

    [3] => Array
        (
            [0] => post/update
            [1] => postHandler
            [2] =>开发者_运维知识库; update
        )

    [4] => Array
        (
            [0] => post/delete
            [1] => postHandler
            [2] => delete
        )

)

I want only the values like admin/login, LoginHandler,index, post,PostHandler,index, post/create,PostHandler,create and so on.So how to do that?


You can loop through the array to perform an action on each element:

foreach ( $your_array as $element ) {
    if ( is_array( $element ) ) {
        foreach ( $element as $sub_element ) {
            // You can store this value in a variable, or output it in your desired format.
            echo $sub_element . "<br />";
        }
    }
    else {
        echo $element . "<br />";
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号