Php 注意:未定义的偏移量:4英寸
当我想用curl绘制数据时,会出现这样的错误 注意:第52行的未定义偏移量:1 in/home/xxx/public_html/xxx/data.php 代码是:Php 注意:未定义的偏移量:4英寸,php,undefined,offset,explode,Php,Undefined,Offset,Explode,当我想用curl绘制数据时,会出现这样的错误 注意:第52行的未定义偏移量:1 in/home/xxx/public_html/xxx/data.php 代码是: function draw($one,$two,$number,$resource) { $draw= explode($one,$resource); $draw= explode($two,$draw[$number]); $draw= $draw[0]; return $draw; } P
function draw($one,$two,$number,$resource) {
$draw= explode($one,$resource);
$draw= explode($two,$draw[$number]);
$draw= $draw[0];
return $draw;
}
Php代码:
$resource2 = curl_exec($ch);
$date = draw('name="popupCal_input" type="text" value="','"',1,$resource2 );
$formid = draw('<form id="','" name="',3,$resource2 );
$validate = draw('<input type="text" name="','" value="',1,$resource2 );
$validateval = draw('id="javax.faces.ViewState" value="','" autocomplete="off"',4,$resource2 );
$submit = draw('<input type="submit" name="','" value="',1,$resource2 );
$resource2=curl\u exec($ch);
$date=draw('name=“popupCal_input”type=“text”value=“”,“”,1,$resource2);
$formid=draw(“您的代码使用分隔符$one
拆分字符串$resource
,然后获取该字符串索引$number
处的部分,并基于分隔符$two
将其拆分,然后返回第一部分
您遇到的问题是,当使用$one
拆分$resource
时,没有$number
部分。您可以插入以下行以捕获该部分:
//...
$draw = explode($one,$resource);
if (count($draw) <= $number) {
return '';
}
$draw= explode($two,$draw[$number]);
//...
/。。。
$draw=explode($1,$resource);
如果(计数($draw)您认为我们如何猜测变量中的内容?魔法?请用缺少的信息更新您的问题。我编辑了我的答案,并添加了一个示例调用,解释了错误。希望它现在能帮助您。如果没有,并且您仍然得到相同的错误,请提供一个引发错误的示例字符串。
$input =
'<div>
<input type="text" name="terminator" value="I\'ll be back">
<input type="text" name="snakesonaplane" value="Enough is enough. I have had it with these motherf***ing snakes on this motherfu***ing plane.">
</div>';
$output = draw('<input type="text" name="', '" value="', 1, $input);
//$output = 'terminator" ';