0
这是我的功能PHP strpos函数添加值
<?php
function checkname($arr, $name) {
foreach (array_slice(func_get_args(), 1) as $name) {
if (strpos($arr, $name) !== false) {
return $name;
}
}
return '';
}
?>
这样我就可以使用这种方式,
$_val = checkname($arr[$i], 'image1', 'image3', 'image2'........);
但是如果我做一个变量像
$newVal = “image1”,“image3”,“image2”,“stores1”,“stores2”,“stores”,“stores3”,“stores4”,“design1”,“design2”
$_val = checkname($arr[$i], $newVal);
这种方式不工作,不会得到任何结果或$newVal
有成为一个数组?
因为对于'$ newVal'的语法无效。为此目的使用一个数组(+也许''call_user_func_array()') – kero