souradipm 0 Report post Posted August 19, 2006 (edited) Hey,I am currently making a program with php and I need to know an answer - I need to know the wildcard for all.It may sound stupid, I know it is *(asterisk) but does php support it? if ($var="Sometext".*) { //code here}Will that work? Any other solutions?Thanks in advance,souradipm Edited August 19, 2006 by souradipm (see edit history) Share this post Link to post Share on other sites
yordan 10 Report post Posted August 19, 2006 What about testing this syntax on your own PC ?You download "easy php" from http://www.easyphp.org/ , the installation lasts half a minute, and you have a working webserver with php, then you put your program in a subfoler of the "www" folder and you test it !Of course, waiting for an answer in this forum may give a faster answer, however having a working testing environment is usually very interesting.RegardsYordan Share this post Link to post Share on other sites
souradipm 0 Report post Posted August 19, 2006 Thing is, my computer is a family PC and I don't want to turn it into a webserver. Also, this code is actually part of a larger program, making it so that I have to complete the program to actually test it out.~souradipm Share this post Link to post Share on other sites
vujsa 0 Report post Posted August 20, 2006 Unless someone knows better than me, I think the solution will require some pattern matching using a regular expression. This will probably confuse you: http://forums.xisto.com/no_longer_exists/ This is the example that best matches your situation: http://us3.php.net/manual/en/function.preg-match.php <?php// The "i" after the pattern delimiter indicates a case-insensitive searchif (preg_match("/php/i", "PHP is the web scripting language of choice.")) { echo "A match was found.";} else { echo "A match was not found.";}?> Of course, you'll need a reg_ex for your situation: I think this will work for you: "/sometext\.([^ ]*)/i" All together: if (preg_match("/sometext\.([^ ]*)/i", "sometext.html")) { echo "A match was found.";} This will match anything after "sometext." except a space! So "sometext.%$^%" is ok but "sometext. Hello" is not! You should try to specify what the extention sould be. Like any letter or number only would be: "/sometext\.([A-Za-z0-9-]{1,})/i"Which means match at least "1" of any upper or lower case letter or number.The upside to that is that it will end at either a whitespace or some non-alpha-numeric character like a punctuation mark or special character. If you want to specify that the extention is at least 3 characters long then use this: "/sometext\.([A-Za-z0-9-]{3,})/i" If you want more leadway on the size of the extention, you could specify between 2 and 4 characters like this: "/sometext\.([A-Za-z0-9-]{2,4})/i" For exactly 3 characters long only, use this: "/sometext\.([A-Za-z0-9-]{3})/i" I hope this helps. vujsa Share this post Link to post Share on other sites