Welcome Guest, Not a member yet? Register   Sign In
general php problem - ereg question
#1

[eluser]skattabrain[/eluser]
OK, so i upgraded php and looks like ereg and ereg replace are gone! so i have some old code in there, in regards to checking credit cards. I don't know what 2nd condition is doing ... the !ereg('5[1-5]', $ccnum)

Code:
if ($type == 'mastercard')
{
if (strlen($ccnum) != 16 || !ereg('5[1-5]', $ccnum)) return false;
}
#2

[eluser]skattabrain[/eluser]
also ... i need a substitute for this ...

Code:
$in = ereg_replace("[^A-Za-z0-9 -.]", "", $in);

my regex skills blow! i need to to basically string out anything that isn't alphanumeric
#3

[eluser]skattabrain[/eluser]
never mind ... preg_replace
#4

[eluser]Phil Sturgeon[/eluser]
Don't use ereg, its deprecated in PHP 5.3.
#5

[eluser]skattabrain[/eluser]
[quote author="Phil Sturgeon" date="1267467940"]Don't use ereg, its deprecated in PHP 5.3.[/quote]

Thanks Phil ... I see you haven't had your morning coffee? Smile

I upgraded PHP to the latest and yes, they are deprecated, I was trying to find a suitable replacement ... seeing my site was barfing some errors.

Hey ... looks like your Pyro is coming of age? I need to check that out again later.
#6

[eluser]Phil Sturgeon[/eluser]
It wasn't coffee I was lacking, just sugar. One large Sprite later and I'm ready to give a slightly more useful answer.

This should help with most of it, but the the 2nd expression should be:

Code:
$in = preg_replace('/([^A-Za-z0-9 -.])+/', '', $in);




Theme © iAndrew 2016 - Forum software by © MyBB