例如搜索“ok”就会匹配ok里面的数组 “你好,good,很好\"打印出来如果搜索“好”没有匹配到第一数组,就会模糊搜索所有含有“好”的的关键词,例如“你好 很好 爱好”
如下面例子:
代码如下 | 复制代码 |
$foo[1]['a']['xx'] = 'bar 1'; |
如果要查找 bar 3 怎么进行查找呢。有三个结果,而这三个结果都要,看下面的函数:
-------------------------------------------------------------------------------------------------------------------------------
代码如下 | 复制代码 |
function array_search_re($needle, $haystack, $a=0, $nodes_temp=array()){ global $nodes_found; $a++; foreach ($haystack as $key1=>$value1) { $nodes_temp[$a] = $key1; if (is_array($value1)){ array_search_re($needle, $value1, $a, $nodes_temp); } else if ($value1 === $needle){ $nodes_found[] = $nodes_temp; } } return $nodes_found; } |
---------------------------------------------------------------------------------------------------------------------------------
这个函数就可以把上面要查找到的内容全部返回出键名来
代码如下 | 复制代码 |
$result = array_search_re('bar 3', $foo); print_r($result); |
输出结果为如下:
Array ( [0] => Array ( [1] => 2 [2] => a [3] => bb )
[1] => Array ( [1] => 3 [2] => c [3] => dd )
[2] => Array ( [1] => 3 [2] => f [3] => gg )
)
1 php搜索多维数组的键名
代码如下 | 复制代码 |
function array_search_key($needle, $haystack){ foreach ($haystack as $key1=>$value1) { return $nodes_found; print_r($result); |
输出结果为如下:
代码如下 | 复制代码 |
Array [1] => Array [2] => Array ) |
类似全文匹配!用二个循环 第一个循环keys 第二个模糊匹配 用函数strstr() 来解决

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

WebStorm-Mac-Version
Nützliche JavaScript-Entwicklungstools

MantisBT
Mantis ist ein einfach zu implementierendes webbasiertes Tool zur Fehlerverfolgung, das die Fehlerverfolgung von Produkten unterstützen soll. Es erfordert PHP, MySQL und einen Webserver. Schauen Sie sich unsere Demo- und Hosting-Services an.

SublimeText3 Linux neue Version
SublimeText3 Linux neueste Version

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor