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!
Moderator: General Moderators
mikebr
Forum Contributor
Posts: 243 Joined: Sat Sep 28, 2002 7:05 am
Post
by mikebr » Sun Oct 09, 2005 9:49 am
I have come accross the following which I think means the first char of the returned value:
Code: Select all
if ($row['variable']{0}!='+') {
// We DO NOT have an + as the first char of the string
} else {
// We have an + as the first char of the string
}
Can someone just confirm this?
Thanks
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun Oct 09, 2005 10:30 am
It does yes. Strings are treated like arrays. That's the way to get that character from the "array". Not sure but I think you can give it a range like $foo{2,5} (Although that's what substring does anyway
)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Oct 09, 2005 11:22 am
d11wtq wrote: Not sure but I think you can give it a range like $foo{2,5}
not in 5.0.4
pilau
Forum Regular
Posts: 594 Joined: Sat Jul 09, 2005 10:22 am
Location: Israel
Post
by pilau » Sun Oct 09, 2005 11:34 am
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Sun Oct 09, 2005 12:16 pm
Not unless variable was a multidimensional array, not a string.
Skara
Forum Regular
Posts: 703 Joined: Sat Mar 12, 2005 7:13 pm
Location: US
Post
by Skara » Sun Oct 09, 2005 6:03 pm
I believe you could once upon a time, but they changed it. Dunno.