Exploding !!!

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

Post Reply
User avatar
Weasel5-12
Forum Commoner
Posts: 37
Joined: Tue Sep 16, 2008 6:58 am

Exploding !!!

Post by Weasel5-12 »

Just a small question.

How can I, if possible (in a simple way), expode a variable consisting of one word, whereby I wish to store the letters in in an array?

I understand that you cannot have a NULL deliminator in the explode function, hence why i pose the question here.


thankyou in advance for any and all assistance.



weasel
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

Re: Exploding !!!

Post by Cirdan »

I believe you can access each character as if it were an array already.

Just tested it, and it works.

Code: Select all

 
$text = 'this is my string';
echo $text[0]; // returns t
 
User avatar
Weasel5-12
Forum Commoner
Posts: 37
Joined: Tue Sep 16, 2008 6:58 am

Re: Exploding !!!

Post by Weasel5-12 »

thankyou very much.

very much appreciated
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Exploding !!!

Post by Mark Baker »

Weasel5-12 wrote:How can I, if possible (in a simple way), expode a variable consisting of one word, whereby I wish to store the letters in in an array?
You can use the str_split() function
Post Reply