PHP如何检索数组值 [英] PHP how to retrieve array values
本文介绍了PHP如何检索数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下数组,我想检索name
,comment
和each of the tags
(以插入数据库中.如何检索数组值.此外,我只能过滤大于以下值的标签值3个字符,仅包含a-Z0-9值.非常感谢.
I have following array, I want to retrieve name
, comment
and each of the tags
(to insert in database. How can i retrieve the array values. Also, can i filter ONLY the tags values which are larger than 3 characters and contains only a-Z0-9 valueus. Thank you very much.
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
然后您可以遍历标记,例如:
You can then loop over the tags like:
foreach ($tags as $tag) {
// do something with tag
}
或单独访问每个人
echo $tags[0];
echo $tags[1];
这篇关于PHP如何检索数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文