Re: [PHP] newbie: string to char array
On Wed, 10 Nov 2004 15:56:28 -, Ford, Mike <[EMAIL PROTECTED]> 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 or a char* ? char * in a zval (and you really shouldn't use deque, 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] newbie: string to char array
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 10 November 2004 16:19, raditha dissanayake wrote: > Ford, Mike wrote: > > > To view the terms under which this email is distributed, > please go to http://disclaimer.leedsmet.ac.uk/email.htm > > > are you in a position to impose any terms (not that i have > visited your > link) on an email that get's distributed to thousands of > readers, get's > archived on hundreds of sites and possibly ends up in the > inbox of bots > designed to harvest email addresses? No. But I'm also not in a position to prevent this ludicrosity from being prefixed to all outgoing mail from where I work. I would suppress it if I could, but I can't. Sorry. You'll just have to judge whether the general standard of my replies warrants putting up with the noise factor, but I would understand entirely if you filtered me to /dev/null. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] newbie: string to char array
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm 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!) > > > mySplit('example') == array('e', 'x', 'a', 'm', 'p' 'l' 'e') ? > > > > Do you absolutely need it as an array? If indexing by character > > would suffice, just use PHP's {} syntax: > > > > $s = 'example'; > > echo $s{0};// e > > echo $s{1};// x > > // etc. > > I am thinking about complexity. > How is a string implemented in PHP? A deque or a char* ? Pass -- this looks like a question for PHP's developers, not the denizens of php-general who are mostly just humble users. But I would expect a char*. > 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? Given the nature of PHP, I'd be astonished if it did 1. But again, this looks more like a question for the PHP developers, not php-general. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie: string to char array
Ford, Mike wrote: To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm are you in a position to impose any terms (not that i have visited your link) on an email that get's distributed to thousands of readers, get's archived on hundreds of sites and possibly ends up in the inbox of bots designed to harvest email addresses? -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] newbie: string to char array
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm > -Original Message- > From: Horst Jäger [mailto:[EMAIL PROTECTED] > Sent: 10 November 2004 09:51 > > I wonder if it is possible to convert a given string into an > array of chars > without using a separator. > > That is, is there a function > > mySplit > > with > > mySplit('example') == array('e', 'x', 'a', 'm', 'p' 'l' 'e') ? Do you absolutely need it as an array? If indexing by character would suffice, just use PHP's {} syntax: $s = 'example'; echo $s{0};// e echo $s{1};// x // etc. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie: string to char array
Horst Jäger wrote: Hi, I wonder if it is possible to convert a given string into an array of chars without using a separator. That is, is there a function mySplit with mySplit('example') == array('e', 'x', 'a', 'm', 'p' 'l' 'e') ? $chars_array = preg_split('//', 'example', -1, PREG_SPLIT_NO_EMPTY); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie: string to char array
Hi, I wonder if it is possible to convert a given string into an array of chars without using a separator. That is, is there a function mySplit with mySplit('example') == array('e', 'x', 'a', 'm', 'p' 'l' 'e') ? Thanks Horst Horst Jäger Schaafenstr. 25 50676 Köln Tel: 0221/93187015 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php