php 如果数组的大小大于 1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6961847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
if size of array is greater than 1
提问by livinzlife
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="_blank" href="'.implode('" rel="lightbox['.
$post->ID.']" class="single_image" title="'.$lightHtml.'<br /><a href="'.
$desclinkurl.'">'.$desclink.'</a>"></a><a href="',$custgalarr).'"
rel="lightbox['.$post->ID.']" class="single_image" title="'.$lightHtml.'<br /><a
target="_blank" href="'.$desclinkurl.'">'.$desclink.'</
a>"></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!
帮帮我,先谢谢了!
回答by Alex Turpin
In PHP it's
在 PHP 中它是
if (count($custgalarr) > 1)
回答by Shackrock
回答by dr. null
<?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.");
}
?>