RE: newbie: string to char array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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<char> 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: m.ford@xxxxxxxxxxxxxx
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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux