To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Code CritiqueHaving someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.
__________________
Bubble
Honest, it is me. I'm a muppet! I've forgoten my passoword and my email address is my work one so I can't get it while I'm at home.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Last edited by Weedpacket; 10-07-2003 at 07:21 PM.
Location: Flying... always flying (apart from when crashed)
Posts: 1,299
Ahh, weedpackets first code example seems a much simpler way, and considering that strlen(substr(foo,1)) = strlen(foo)-1 (which I hadn't realised) is a short hop from my example.
The regexp snippet however does intrigue me, and would be my choice - if only I understood it fully. I have seen somewhere, an explanation of them, but can't find it again... anyone point me in the right direction ?
Pyrox - while the function is valid - I was looking for more of a one liner - as code space is a consideration...
__________________
The Chancer
----------------
Does This Mean I'm Bored
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,126
Quote:
Originally posted by The Chancer The regexp snippet however does intrigue me, and would be my choice - if only I understood it fully. I have seen somewhere, an explanation of them, but can't find it again... anyone point me in the right direction ?
I've actually been considering writing a PHPBuilder article on the subject myself for some time.
Something I've realised a little later about that regexp is how easily it could be modified to get the grandparent directory instead of the parent. The bit to check out is the {2}. If that were replaced by {0} you'd get everything, including the file itself. If it's {1} you get the path up to and including the directory in which the file resides. Use {2} and you get the path to the parent directory. {3} gives you the grandparent's path, and so on up the whakapapa.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
__________________
-Karl Problem solved? Mark your thread resolved!
See how many times my link has been used to mark a thread resolved here
(fixed to work with updated VBulletin... this works again!)