你可以这样做 array_map()
$a = array('1str', '2str', '3str');
$str ='123 2str 3str 1str';
function my_strpos($needle) {
global $str;
return strpos($str, $needle);
}
$positions = array_map('my_strpos', $a);
Run Code Online (Sandbox Code Playgroud)
print_r($positions); 得到:
Array
(
[0] => 14
[1] => 4
[2] => 9
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
145 次 |
| 最近记录: |