我有以下数组,我想检索 namecommenteach of the tags (插入数据库。如何检索数组值。另外,我可以仅过滤大于 3 个字符且仅包含 a-Z0- 的标签值吗? 9 valueus 非常感谢。

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

        )

)

最佳答案

$name = $array['name'];
$comment = $array['comment'];
$tags = $array['item']['tags']; // this will be an array of the tags

然后,您可以遍历标签,例如:
foreach ($tags as $tag) {
  // do something with tag
}

或单独访问每个
echo $tags[0];
echo $tags[1];

关于PHP如何检索数组值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5568901/

10-12 12:29
查看更多