PHP 7.3 警告:count(): 参数必须是数组或实现了Countable的对象
PHP 7.3 Warning: count(): Parameter must be an array or an object that implements Countable
Warning: count(): Parameter must be an array or an object that implements Countable
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<count($tags)+1;$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
print_r($tags);
使用它并检查标签的输出。
它可能为空,所以你会像 this.check
`locchuoi($request,"<span class='SeoH1'>",'</span>');`
此函数返回您需要的准确输出。
简单地将Count
替换为!empty
你的问题就解决了
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<=(!empty($tags) ? count($tags) : 0);$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<(!empty($tags) ? count($tags)+1 : 0);$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
试试这段代码,我只是在 for() 中添加了一些条件,当 $tags 变量为空时 return 0 ,如果不是 return count($tags)+1 .
Warning: count(): Parameter must be an array or an object that implements Countable
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<count($tags)+1;$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
print_r($tags);
使用它并检查标签的输出。 它可能为空,所以你会像 this.check
`locchuoi($request,"<span class='SeoH1'>",'</span>');`
此函数返回您需要的准确输出。
简单地将Count
替换为!empty
你的问题就解决了
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<=(!empty($tags) ? count($tags) : 0);$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<(!empty($tags) ? count($tags)+1 : 0);$ll++)
{
$tag_link = $tag_link.$tags[$ll].",";
}
试试这段代码,我只是在 for() 中添加了一些条件,当 $tags 变量为空时 return 0 ,如果不是 return count($tags)+1 .