PHP if语句检查是否等于相同的数字

时间:2015-03-23 04:51:25

标签: php variables if-statement preg-match

我正在尝试检查变量是否匹配以及它们是否匹配显示此信息。

这是我到目前为止所做的:

<?php

list($ccvRecords, $ccvMetaData) = getRecords(array(
'tableName'   => 'videos',
'loadUploads' => true,
'where' => "num NOT LIKE '%{$CurrentCCVideo}%'",
'allowSearch' => false,

));

list($ccvSelRecords, $ccvSelMetaData) = getRecords(array(
'tableName'   => 'videos',
'loadUploads' => true,
'allowSearch' => false,

));

&GT;

<?php foreach($ccvSelRecords as $record) : ?>
<?php if ($CurrentCCVideo === $record['num']) : ?>
<label class="margin-top-10"><?php echo($record['title']) ?> is selected</label>
<input type="checkbox" class="form-control input-lg" name="meta_keywords" onClick="dosomething" value="0">
<?php else : ?>
<label class="margin-top-10"><?php echo($record['title']) ?></label>
<input type="checkbox" class="form-control input-lg" name="meta_keywords" onClick="dosomething" value="0">
<?php endif ?>
<?php endforeach ?>

3 个答案:

答案 0 :(得分:0)

变化

if (($CurrentCCVideo = $record['num'])==TRUE)

if (($CurrentCCVideo == $record['num']))

答案 1 :(得分:0)

替换

<?php if (($CurrentCCVideo = $record['num'])==TRUE) : ?>

<?php if ($CurrentCCVideo == $record['num']) : ?>

立即尝试..

答案 2 :(得分:0)

你可以使用

if(is_numeric($element))
{
 //your code 
}

<?php foreach($ccvRecords as $record) : ?>
<?php if ($CurrentCCVideo ==== $record['num']) : ?>
<label class="margin-top-10"><?php echo($record['title']) ?> is selected</label>
<input type="checkbox" class="form-control input-lg" name="meta_keywords" onClick="dosomething" value="0">
<?php else : ?>
<label class="margin-top-10"><?php echo($record['title']) ?></label>
<input type="checkbox" class="form-control input-lg" name="meta_keywords" onClick="dosomething" value="0">
<?php endif ?>
<?php endforeach ?>