Re: newbie: string to char array

From: Date: Thu, 11 Nov 2004 06:02:41 +0000
Subject: Re: newbie: string to char array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201739@lists.php.net to get a copy of this message
On Wed, 10 Nov 2004 15:56:28 -0000, Ford, Mike <M.Ford@leedsmet.ac.uk> wrote:
On 10 November 2004 13:37, Horst Jäger wrote: (Please keep this on list -- others may be able to help better/faster than me!)
I am thinking about complexity. How is a string implemented in PHP? A deque<char> or a char* ?
char * in a zval (and you really shouldn't use deque<char>, given the existance of string)
How does $s{n} acces the n-th char? 1. Does it go to the beginning of the string and then jump from one char to the next, counting the instances and return when the n-th ionstance is reached? 2. Or does it jump to the n-th char directly?
I haven't benchmarked it, but I would assume strings derefing is signficantly faster than arrays, as arrays in php are actually hashtables, while $a{5} is just a straight deref. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ http://www.smempire.org

« previous php.general (#201739) next »