我希望对一个数组执行搜索,并在找到匹配项时返回所有值。我要在数组中搜索的关键字是 [name]
。
Array (
[0] => Array
(
[id] => 20120100
[link] => www.janedoe.com
[name] => Jane Doe
)
[1] => Array
(
[id] => 20120101
[link] => www.johndoe.com
[name] => John Doe
)
)
如果我搜索 John Doe ,它会返回结果。
Array
(
[id] => 20120101
[link] => www.johndoe.com
[name] => John Doe
)
如果根据我的搜索内容重命名数组,是否会更容易?除了上面的数组外,我还可以生成以下数组。
Array (
[Jane Doe] => Array
(
[id] => 20120100
[link] => www.janedoe.com
[name] => Jane Doe
)
[John Doe] => Array
(
[id] => 20120101
[link] => www.johndoe.com
[name] => John Doe
)
)