我有以下数组,包含10,000多个条目
1895] => CHQ N SUMEET KHUITAN DEP BY VAIBHAV MONEY TRANS
[1896] => CR
[1897] => 85,000.00 Not Available Not Available Not Available Not Available TCI 01/12/13 01/12/13
[1898] =>
[1899] => 2 S32324176 01/12/13
[1900] =>
[1901] => <444209603509>MY FINANCE LTD
[1902] => CR
[1903] => 8,00,000.00 Not Available Not Available Not Available Not Available TBI 01/12/13 01/12/13
[1904] =>
[1905] => 2 S32323871 01/12/13
[1906] =>
[1907] => EARTH SUB REMIT, BOHORA TAR
[1908] => CR
[1909] => 2,00,000.00 Not Available Not Available Not Available Not Available TCI 01/12/13 01/12/13
[1910] =>
[1911] => 1319 S32321414 01/12/13
[1912] => 1000786233
[1913] => INWARD CLEARING NPR
[1914] => DR
[1915] => 1,00,00,000.00 Not Available Not Available Not Available Not Available LI 01/12/13 01/12/13
[1916] =>
[1917] => 2 DC9032 01/12/13
[1918] =>
[1919] => HAMRO BIKASH BANK
[1920] => CR
[1921] => 13,00,000.00 Not Available Not Available Not Available Not Available TCI 01/12/13 01/12/13
[1922] =>
[1923] => 1 DC7192 01/12/13
[1924] =>
[1925] => SP TRADING CASH DEPOSIT
[1926] => CR
[1927] => 36,140.00 Not Available Not Available Not Available Not Available CNR 01/12/13 01/12/13
[1928] =>
[1929] => 2 S32318770 01/12/13
[1930] =>
[1931] => <444990698490>good FINANCE LTD
[1932] => CR
[1933] => 35,00,000.00 Not Available Not Available Not Available Not Available TBI 01/12/13 01/12/13
从这些条目我想要考虑以'&lt;'开头的数组保留原始索引
即
[1901] => <444209603509>MY FINANCE
[1931] => <444990698490>good FINANCE
我做了以下
foreach($arr as $key=>$val){
if(substr($val,0,1)=='<')
$new_arr[$key]=$val;
}
print_r($new_arr);
我真的放慢了脚本的速度,我们没有其他选择,比如 array_filter
答案 0 :(得分:1)
在PHP中尝试array_filter。该函数检查数组值是否以<
开头。
function myFilter($val){
$val = trim($val);
return ($val[0]==='<');
}
array_filter($array,'myFilter');