Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if size of array is greater than 1

Tags:

arrays

php

sizeof

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!

like image 824
livinzlife Avatar asked Aug 05 '11 19:08

livinzlife


2 Answers

In PHP it's

if (count($custgalarr) > 1)
like image 159
Alex Turpin Avatar answered Oct 23 '22 19:10

Alex Turpin


in PHP:

count()

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

like image 1
Shackrock Avatar answered Oct 23 '22 19:10

Shackrock