Hi, Sunday, April 25, 2004, 3:15:25 PM, you wrote:
AB> ok sorry but since i never used preg_* before i dont quite get what some of AB> this stuff means. i looked at the doc page for it but it doesnt make mention AB> at all of what \d, \w, \s or any of those things mean... i only assume that AB> \d means digit and \w or \s means blank space?? AB> anyways to go through the whole example above part by part: AB> $phone = '1234567890';//understand that AB> $newphone = preg_replace(//ok now what does this stuff AB> //mean?? AB> '/(\d{3})(\d{3})(\d)/' AB> im gathering the line above is the search string (what to look for)? if so i AB> get from it that it is supposed to look for the first block of 3 digits then AB> the second block of 3 digits and the other 4 numbers by themself in a sense AB> seperating the string into 3 different parts: 123 456 7890 and then asigning AB> like "id numbers to the blocks" AB> '(\1)\2-\3' AB> and this one above says put block 1 between (). take block 2 and put a - AB> after it and leave the other 4 numbers alone to come up with: (123)456-7890 AB> $phone); AB> the original number to do the replace on of course AB> let me know if i got that set right Yes that is exactly what it does .. sorry probably should have explained it... but at least you read up the function :-) the () tells preg to store the contents and they get numbered 1 2 3 .. the \1 with a number below 10 tells it to use what it captured at that point. \D btw captures everything that is not a digit so you can use that to cleanup the user input with $input = preg_replace('/\D/','',$input); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php