如果数组的大小大于1。

时间:2023-01-15 09:46:22

I have an end of a link set, but I only want a portion to be used UNLESS the size of an array is greater than 1.

我有一个链接集的末尾,但是我只希望使用一部分,除非数组的大小大于1。

$closeLink='</a>'.'<a target=&quot;_blank&quot; href="'.implode('" rel="lightbox['.
$post->ID.']" class="single_image" title="'.$lightHtml.'<br />&lt;a href=&quot;'.
$desclinkurl.'&quot;&gt;'.$desclink.'&lt;/a&gt;"></a><a href="',$custgalarr).'"
rel="lightbox['.$post->ID.']" class="single_image" title="'.$lightHtml.'<br />&lt;a 
target=&quot;_blank&quot; href=&quot;'.$desclinkurl.'&quot;&gt;'.$desclink.'&lt;/
a&gt;"></a>';

So everything after the part shown isolated below needs to only show if the size of the array $custgalarr is greater than 1:

因此,下面显示的独立部分后面的所有内容只需要显示数组$custgalarr是否大于1:

$closeLink='</a>'

I figure I need to use something like this after the closing a tag

我想我需要在结束标签之后使用类似的东西

if (sizeof($custgalarr) > 1){

Help me out, thanks in advance!

先帮我一下,谢谢!

3 个解决方案

#1


25  

In PHP it's

在PHP

if (count($custgalarr) > 1)

#2


0  

in PHP:

在PHP中:

count()

http://php.net/manual/en/function.count.php

http://php.net/manual/en/function.count.php

#3


-3  

<?php

function wordlength($txt, $limit)
{
   $words = explode(' ', $txt);
   foreach($words as $v)
   {
       if(strlen($v) > $limit)
       {
            return true;
       }
   }
   return false;
}

$txt = "1";

if(!wordlength($txt, 1))
{
    die("String is less than or equal to one.");
}

?>

#1


25  

In PHP it's

在PHP

if (count($custgalarr) > 1)

#2


0  

in PHP:

在PHP中:

count()

http://php.net/manual/en/function.count.php

http://php.net/manual/en/function.count.php

#3


-3  

<?php

function wordlength($txt, $limit)
{
   $words = explode(' ', $txt);
   foreach($words as $v)
   {
       if(strlen($v) > $limit)
       {
            return true;
       }
   }
   return false;
}

$txt = "1";

if(!wordlength($txt, 1))
{
    die("String is less than or equal to one.");
}

?>

相关文章