PHP如何检索数组值

Aja*_*jay 4 php arrays

我有以下数组,我想检索name,commenteach of the tags(在数据库中插入.如何检索数组值.另外,我只能过滤大于3个字符的标签值,并且只包含一个-Z0-9值.非常感谢你.

Array
(
    [folder] => /test
    [name] => ajay
    [comment] => hello world.. test comment
    [item] => Array
        (
            [tags] => Array
                (
                    [0] => javascript
                    [1] => coldfusion
                )

        )

)
Run Code Online (Sandbox Code Playgroud)

RDL*_*RDL 5

$name = $array['name'];
$comment = $array['comment'];
$tags = $array['item']['tags']; // this will be an array of the tags
Run Code Online (Sandbox Code Playgroud)

然后,您可以遍历标记,如:

foreach ($tags as $tag) {
  // do something with tag
}
Run Code Online (Sandbox Code Playgroud)

或单独访问每一个

echo $tags[0];
echo $tags[1];
Run Code Online (Sandbox Code Playgroud)