16 Jul 2003 trukfixer   » (Journeyer)

Hmm.. went to add a note at php.net.. doesnt seem to have taken it.. some reason I intermittently get page not found errors over there.. anyhow, I was gonna put this under the abs() notes, may as well post here too. input always appreciated..:)

assume we take user input from a form untreated and assign it to variable $range. We want to be sure this number is a Positive Whole number, since abs() just sets a number to positive or 0, and we dont want decimals...

if(!is_numeric($range))//checks for numeric input
//sets $range to integer 1 if input is anything other than a numeric value
if(!int($range))//checks to make sure it is an integer (not decimal)
//if a decimal- sets $range to integer value
$range=abs($range);//sets value to positive whole number

for example the input "testing" would return $range =1, the input "3.578" would return value=3 If the input is null, I am havent tested to see if it gets set to 1 courtesy of int_val or not, but I believe it will be.

I'm sure there's probably a more elegant way to do this using regex, however for an apprentice php coder, this might be a little easier to understand and use.

anyhow, I've been digging around on the use of regular expressions in php, finding some interesting ideas..

personally, Im in a fairly decent mood. although Im collecting lots of scratches from my new kitten.. he's nuts. flying all over the place like a little hellraiser.. middle of night he decided to play with my hair, leaving 3 nice scratches on my forehead.. he also decided to chat with a friend who said hello early morning while I slept... if you can make sense of ".....////////////////'''''''''''']]]]]]]]]]]]hhhhhhhhhhhhhh"

let me know.. I'm not sure whether he was saying "hi" or "get lost, dude, let Bri sleep!"

kind of slow at work.. being on flat rate, my paycheck this week is gonna REALLY suck..:(

Oh well.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!