php doesn't have as loose a syntax as perl or python. try this:

<?
$testString = "this=is=something";
print array_shift(split("=",$testString));
?>

mind you, that only works because you wanted the 0th element, and shift
returns that first one...something else would be needed for any other
index...

jack

-----Original Message-----
From: Ray Van Dolson [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 14, 2001 10:14 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Why doesn't this work?


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];

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?

Anyways, thanks for any help.  I guess I'm just too used to Python. :-D

Ray Van Dolson

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to