我有一个 mysql 结果数组,我正在尝试使用 array_walk 在数组上删除斜杠。它不是从 mysql 中剥离斜杠。它正在处理我手动添加的数组 ($dataArr['xxx'])。
这是我的代码:
$sql = ' select * from `ads` where id = 3 ';
$res = mysql_query($sql, $conn) or die(mysql_error());
$row = MYSQL_FETCH_ASSOC($res);
$dataArr = $row;
$dataArr['xxx'] = '<script type=\'text/javascript\'><!--//<![CDATA[
var m3_u = (location.protocol==\'https:\'?\'https://ads.test.com/www/delivery/ajs.php\':\'http://ads.test.com/www/delivery/ajs.php\');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = \',\' etc.... etc....;
';
array_walk_recursive($dataArr, 'stripslashes');
print '<pre>'; print_r($dataArr); print '</pre>';