PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
timvw wrote:Edit: Although it's shorter, it's slower... I feel ashamed Razz time to go to bed Smile Night All.
But not by that much, most likely you will not even notice a difference. Although, it is best to get in the habbit to avoid initializing regex engine when possible.
timvw wrote:Edit: Although it's shorter, it's slower... I feel ashamed Razz time to go to bed Smile Night All.
But not by that much, most likely you will not even notice a difference. Although, it is best to get in the habbit to avoid initializing regex engine when possible.
I haven't checked performance and I'm not likely to either, I'll take your word on it. However, the pure preg function posted also doesn't return false for numbers that are not 7 or 10 digits in length, it's just blindly working away which is not (in my opinion) the best approach.
I could still shave a little of that function if I were being really picky
redmonkey wrote:I haven't checked performance and I'm not likely to either, I'll take your word on it. However, the pure preg function posted also doesn't return false for numbers that are not 7 or 10 digits in length, it's just blindly working away which is not (in my opinion) the best approach.
I could still shave a little of that function if I were being really picky
I did a quick benchmark of the two functions. My format was a loop of 100, performed 50 times (so it was performed 5000 times).