如何检查PHP数组中的任何键中是否存在值 [英] How to check if a value exists in any key in PHP array

查看:77
本文介绍了如何检查PHP数组中的任何键中是否存在值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,

我有一个大约20个关键项的数组,每个键有13个值。如果存在,我需要在所有键中搜索特定值,如果存在,我需要该值的键索引。

例如我有

数组



[0] =>数组



[0] => abc

[1] => def

[2] => ghi

[3] => jkl

[4] => mno

[5] => dfdsg

[6] => PIC

[7] => pqr

[8] => 1543

[9] => stu

[10] => wx

[11] => yz

[12] =>我们

[13] => fewfw





从这里我需要搜索def,我需要关键索引def 。

请帮忙。



我尝试过的事情:



$ ids = array_column($ array,'1');

if(isset($ ids [$ array [$ ind] [1]]))

{

}

Hello All,
I have an array of around 20 key items with 13 value in each key. I need to search specific value in all the keys if exists and if it exists I need the key index of that value.
For e.g. I have
Array
(
[0] => Array
(
[0] => abc
[1] => def
[2] => ghi
[3] => jkl
[4] => mno
[5] => dfdsg
[6] => PIC
[7] => pqr
[8] => 1543
[9] => stu
[10] => wx
[11] => yz
[12] => we
[13] => fewfw
)
)
From this I need to search for "def" and I need the key index of "def".
Please help .

What I have tried:

$ids = array_column($array, '1');
if(isset($ids[$array[$ind][1]]))
{
}

推荐答案

ids = array_column(
ids = array_column(


array,'1');

if(isset(
array, '1');
if(isset(


ids


这篇关于如何检查PHP数组中的任何键中是否存在值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆