Welcome Guest. Sign in or Signup

2 Answers

PHP wildcard?

Asked by: 7 views ,

wondering, does the * symbol (asterix) represent a wildcard in php, otherwise, how could i use a wildcard?

so that something like this could be accomplished…

if ($var == ‘.*.’value’.*.’) {foo;}

above, the foo would be executed if $var equaled anything with the word "value" in it. So, foo would be executed if $var equaled "values" or "blablavalueblabla" etc.

Thanks for your response :)

2 Answers



  1. daa on Feb 06, 2012

    What you’re looking for is a regular expression. Here’s a decent tutorial:

    http://www.sitepoint.com/article/regular-expressions-php



  2. Robin T on Feb 06, 2012

    You can just use strpos() to check if a substring exists within a string.

    if (strpos($var, "value") !== false) { foo(); }

    More on strpos(): http://www.php.net/strpos


Answer Question

Powered by Yahoo! Answers