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
}
有没有人?我要为这件事抓狂了.
这是我的$img_tag var_dump
array(1) {
[0]=>
string(97) "<img alt='' src='http://pete1.netsos.com/site/files/newsletter/banner.jpg' align='' border='0px'>"
发布于 2011-10-12 04:32:48
假设$img_tag
是某种类型的对象,而不是正确的字符串,则将$img_tag
强制转换为[]
中的字符串
preg_match_all("/(alt|title|src)=('[^']*')/i",(string)$img_tag, $img[(string)$img_tag]);
//------------------------------------------------------------------^^^^^^^^^
一些对象类型,例如SimpleXMLElement
,将通过magic method __toString()
向print/echo
返回字符串表示,但不能代替常规字符串。除非您通过(string)$obj
将它们转换为正确的字符串,否则尝试将它们用作数组键将产生illegal offset type
错误。
发布于 2011-10-12 04:35:11
$result
为二维array.So,$img_tag
应为数组。
但只能使用整数和字符串作为偏移量
发布于 2016-01-18 11:32:23
foreach( $result[0] as $img_tag)
它起作用了
https://stackoverflow.com/questions/7732109
复制相似问题