Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP非法偏移类型 警告:在第85行的/email_HANDLER.php中输入非法偏移量 $final_message=str_replace($from,$to,$final_message); 预赛/_Php_Warnings - Fatal编程技术网

PHP非法偏移类型 警告:在第85行的/email_HANDLER.php中输入非法偏移量 $final_message=str_replace($from,$to,$final_message); 预赛/

PHP非法偏移类型 警告:在第85行的/email_HANDLER.php中输入非法偏移量 $final_message=str_replace($from,$to,$final_message); 预赛/,php,warnings,Php,Warnings,有人吗?我要为这件事大发雷霆 这是我的$img_标签的var_转储 Warning: Illegal offset type in /email_HANDLER.php on line 85 $final_message = str_replace($from, $to, $final_message); preg_match_all('/<img[^>]+>/i',$final_message, $result); $img = array(); foreach($res

有人吗?我要为这件事大发雷霆

这是我的$img_标签的var_转储

Warning: Illegal offset type in /email_HANDLER.php on line 85

$final_message = str_replace($from, $to, $final_message);

preg_match_all('/<img[^>]+>/i',$final_message, $result);
$img = array();
foreach($result as $img_tag)
{
    preg_match_all("/(alt|title|src)=('[^']*')/i",(string)$img_tag, $img[$img_tag]); //LINE 85
}
数组(1){
[0]=>
字符串(97)”

假设
$img\u tag
是某种类型的对象,而不是正确的字符串,则将
$img\u tag
强制转换为
[]
中的字符串

array(1) {
  [0]=>
  string(97) "<img alt='' src='http://pete1.netsos.com/site/files/newsletter/banner.jpg' align='' border='0px'>"
例如,某些对象类型,特别是
simplexmlement
,将通过返回字符串表示形式到
print/echo
,但不能作为常规字符串。尝试将它们用作数组键将产生
非法偏移类型
错误,除非通过
(字符串)将它们转换为正确的字符串$obj

请参见以下内容的第一条评论:

不能将数组或对象用作键。这样做将导致警告:偏移量类型非法。请检查代码


确保
$img\u tag
为适当的变量类型。

$result
为二维数组。因此,
$img\u tag
应为数组

但只有整数和字符串可以用作偏移量

preg_match_all("/(alt|title|src)=('[^']*')/i",(string)$img_tag, $img[(string)$img_tag]);
//------------------------------------------------------------------^^^^^^^^^

它可以工作

我猜这是SimpleXML节点操作的结果?现在,当我向这两个位置添加(字符串)时,它不会提供我在打印\r$img时所需的字符串…哪是图像位置,有什么想法吗?Post
print\r($result)
这样我们就可以看到你从什么开始。这也值得一看。打得好,我以前从未遇到过。
foreach( $result[0] as $img_tag)