php -compare a partial string

I need to check if a sales code contains certain letters from many variations that are to be entered in a sales discount field.

i.e. all the first 4-7 letters with remain the same, something like OFFER09 and the rest (a number 23467) would just kept as a reference as to who actually ordered.

How you I use php to just check the first few letters (the exact amount of letters is yet to be confirmed)

Or to check the field discount code contains the letters OFFER09.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sorted - strpos()

<?php
if (strpos("OFF0912345678", "OFF09") !== false)
	echo 'Match found';
else
	echo 'Not found';
?>

dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There’s also this:

$match = (substr('OFF0912345678',0,5) == 'OFF09');

That will equal true or false, depending, and it’s much faster.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options