Forum Moderators: coopster

Message Too Old, No Replies

"Scan" a string

         

bobnew32

4:02 am on Aug 22, 2003 (gmt 0)

10+ Year Member



Ok im currently working on an image rendering program, and to be able to render the image you must be at a specific site to render it (not mine so I cant use .htaccess nor want to)

So, I was thinking of being able to "scan" the $HTTP_HOST string and see if a match of the characters I set match. So does anyone know how I would logically write this code in php? Don't worry seeker.com is not full url of the website, but only the end of the website url.

$url= $HTTP_HOST
Scan $url for seeker.com if it matches,
print 'Good a match';
}else{
print 'Oooh no match found';

dmorison

4:06 am on Aug 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To test for example.com in the host:

if (strstr(strtolower($HTTP_HOST),"example.com"))
{
echo("Got a match!");
}
else
{
echo("No match found!");
}

Dolemite

4:13 am on Aug 22, 2003 (gmt 0)

10+ Year Member



From strstr [php.net]:

Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

I.E.:

if(strpos(strtolower($HTTP_HOST),'example.com') > -1)

etc.

bobnew32

4:18 am on Aug 22, 2003 (gmt 0)

10+ Year Member



Hey thanks guys, you have been a great help!