简体   繁体   中英

if size of array is greater than 1

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.

$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:

$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!

在PHP中它是

if (count($custgalarr) > 1)
<?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.");
}

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM