如何查找$ row是否包含某些字符

Having a bit of a coding issue, how can I check to see if the value of a $row['value'] contains certain characters, in this case, if 'rename_file' contains a filename that has '128' in it. I have this but it doesn't seem to echo when it is.

$row = mysql_fetch_assoc($result);
{
while ($row = mysql_fetch_assoc($result))
  {
  echo $row['c_ID'] . " " . $row['source_file'] . " " . $row['rename_file'] ." " . $row['p_ID'];
  if ($row['rename_file'] = '%128%') {
  echo "<p> This is a 128";
  } else
  echo "<br>";
  }
}

Many thanks. CP

Use preg_match():

if(preg_match('/128/',$row['rename_file'])){
    echo "<p> This is a 128";
} else {
    echo "<br>";
}

Or strpos():

if(strpos($row['rename_file'], '128') !== false){
    echo "<p> This is a 128";
} else {
    echo "<br>";
}

Take a look at stristr for searching for keywords. http://php.net/manual/en/function.stristr.php

if (strpos($row['rename_file'], '128') !== false) {
    echo "<p> This is a 128";
}

If you mean to check every value in row for 128:

function searchArray($search, $array)
{
    foreach($array as $key => $value)
    {
        if (stristr($value, $search))
        {
            return true;
        }
    }
    return false;
}

$row = array('c_ID'=>'Prefix_128_ABC','source_file'=>'EFG.xml','rename_file'=>'FOO.xml');
if (searchArray('128',$row) !== false) {
    echo "<p> This is a 128";
}else{
    echo "<p> This is not a 128";
}

Slightly modified from: http://forums.phpfreaks.com/topic/195499-partial-text-match-in-array/

--OOPS! Misread. Well, this is how you would do that if you needed too... --