我是一个有用的助手,可以为您翻译文本。
我正在使用这些数据: 要查找的内容: 'B51MM36'
被搜索的数组:(抱歉,由于无法找到从
我正在尝试调试我写的脚本,并且存在一个问题,即检查标识符是否存在于资产的(多维)数组中。我使用了一个可以递归搜索的in_array函数,该函数来自这个问题。
以下是该函数:
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
我正在使用这些数据: 要查找的内容: 'B51MM36'
被搜索的数组:(抱歉,由于无法找到从
var_export
美化数组的方法,所以数组未被美化)$sedols = array ( 0 => array ( 'ipsid' => '72', 'buyList' => '1', 'sedol' => 'B8LFDR7', 'isin' => 'LU0827876409', 'currency' => NULL, 'hedged' => '0', 'acc' => '0', 'inst' => '0', 'description' => 'BlackRock European Long Only', 'nonUKsitus' => '0', 'reportingStatus' => '0', 'matchScore' => 0, ), 1 => array ( 'ipsid' => '72', 'buyList' => '1', 'sedol' => 'LU0827876151', 'isin' => 'LU0827876151', 'currency' => 'USD', 'hedged' => '1', 'acc' => '1', 'inst' => '0', 'description' => 'Blackrock European Long Only', 'nonUKsitus' => '0', 'reportingStatus' => '0', 'matchScore' => 0, ), 2 => array ( 'ipsid' => '72', 'buyList' => '1', 'sedol' => 'LU0406496546 ', 'isin' => 'LU0406496546 ', 'currency' => 'EUR', 'hedged' => '1', 'acc' => '1', 'inst' => '0', 'description' => 'Blackrock European Long Only', 'nonUKsitus' => '0', 'reportingStatus' => '0', 'matchScore' => 0, ), 3 => array ( 'ipsid' => '72', 'buyList' => '1', 'sedol' => 'LU0827876409', 'isin' => 'LU0827876409', 'currency' => 'GBP', 'hedged' => '1', 'acc' => '0', 'inst' => '0', 'description' => 'Blackrock European Long Only', 'nonUKsitus' => '0', 'reportingStatus' => '1', 'matchScore' => 1, ), );
当我运行 var_dump(in_array_r('B51MM36', $sedols));
,它输出了 bool(true)
。 我感到困惑,因为字符串 'B51MM36'
在干草堆数组中并不存在。 有人能够确定这里发生了什么吗?