PHP Sucks. "PHP is an abomination." - David Robins, December 17, 2002.
[1] character encodings are a pain in the neck, but they are necessary
Some points of my own:
Of course you can write complex scripts in PHP - it's Turing complete. It's just painful. (See Paul Graham's Succinctness is Power article.) You can write complex scripts in assembler; it's also painful. But assembler has a niche, a place where it shines: when you need to hand-optimize something or write low-level code (think kernels, trampolines, compiler magic). PHP doesn't. There's nothing for which it is the best choice.
A simple problem and a perl solution: remove all matches to id=some integer value (at the end of a string) from a list, also stripping off id=value from the other strings. (Admittedly this seems a little contrived but it was actually needed by somebody at some point.)
@array = grep { s/id=(\d+)$// ? $1 != $value : 1 } @array;
[2005-02-04] Finally there's a PHP equivalent from Jason Sweat, after almost 2 years:
$array = array_filter($array, create_function('$v','return !preg_match(\'/id=\d+$|id='.$value.'$/\',$v);'));
At least it's possible, but note the following two things: it has to parse code at runtime (think eval STRING), and that it makes use of perl regular expression matching (beats reinventing the wheel I guess). It just doesn't have the elegance of the perl (IMO).
Site design and content copyright ©2003 David B. Robins. All Rights Reserved. pH?