Re: Why doesn't this work?

From: Date: Sat, 15 Sep 2001 03:55:35 +0000
Subject: Re: Why doesn't this work?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-319@lists.php.net to get a copy of this message
On Sat, Sep 15, 2001 at 02:13:20AM -0000, Ray Van Dolson wrote: This type of message would be more appropriate for php-general, for future reference. > I've come across this problem enough that I want to find out if there's a > way to make it work, or if this is just a limitation of PHP. Here's what > I'm trying to do: > > print split("=",$testString)[0]; > > This gives me a syntax error. I've also tried: > > print (split("=",$testString))[0]; > > Along with other permutations... the only way I can get this to work how > I want it to is to create a temporary variable first. > > $tempVar = split("=",$testString); > print $tempVar[0]; I don't think the engine is really built to handle constructions like that. Your solution is the correct (and most readable, in my opinion) approach to the problem. > Now I guess this is easy enough to do, but I'm just used to doing it the > other way. And the documentation for split() says that it should return > an Array... why can't I operate on it as I would a normal array? Yes, it returns an array, but that doesn't mean that all of the operations can be pipelined as in your attempts. -- Jon Parise (jon@csh.rit.edu) . Information Technology (B.S.) http://www.csh.rit.edu/~jon/ : Computer Science House Member

« previous php.pear.general (#319) next »