Page 1 of 1

Is there an easier way to block things then ereg()?

Posted: Mon Jul 21, 2003 11:01 pm
by php_wiz_kid
In my script I'm using ereg() to block certain number/symbols/letters when passed through an if statement so they don't get entered into a database. Now, I have super long lines of code using the ereg() function. Is there anyway I could put the unwanted numbers/symbols/letters in an external file and import them in so I don't have 150 ereg()'s in one if statement?

...

Posted: Mon Jul 21, 2003 11:05 pm
by kettle_drum
You could add them into an array and then check each letter to see if its in the array using:

in_array();

?>

Posted: Tue Jul 22, 2003 12:06 am
by php_wiz_kid
Would I have to do it with a loop? Could you please send an example. I'm looking at the PHP Manual, and I'm not seeing how I would do it. Thanks.

Posted: Tue Jul 22, 2003 12:17 am
by php_wiz_kid
I figured out what you meant. That wouldn't work, I would have more lines of code now. The ereg() function would be easier. Thanks though.