如果title包含$ variable,则为PHP

时间:2015-12-28 09:00:03

标签: php

我有我的变量$mustcontain,我有以下内容:

if ($getvideoviews >= $minimumvideoviews 
    AND $getvideolikes >= $minimumvideolikes 
    AND $VidDuration >= $minvidlenght 
    AND $getchannelsubscribers >= $minsubs)

我需要检查$videotitle是否包含$mustcontain中的内容,如果为真,则继续显示更多信息

1 个答案:

答案 0 :(得分:0)

您可以使用strpos()in_array()

如果$mustcontain是字符串:

if ($getvideoviews >= $minimumvideoviews 
    && $getvideolikes >= $minimumvideolikes 
    && $VidDuration >= $minvidlenght 
    && $getchannelsubscribers >= $minsubs
    && strpos($videotitle, $mustcontain) !== false) {
        // do sth. with it
    }

如果$mustcontain是数组:

if ($getvideoviews >= $minimumvideoviews 
    && $getvideolikes >= $minimumvideolikes 
    && $VidDuration >= $minvidlenght 
    && $getchannelsubscribers >= $minsubs
    && in_array($videotitle, $mustcontain) !== false) {
        // do sth. with it
    }