Jump to content

[SOLVED] Explode a string by...nothing essentially? Seperate all chars into an array!


Dale_G

Recommended Posts

Hey everyone.

 

Say I have a string, which...could be any combination of letters and numbers.

 

For example.

 

$string = 'fhkhj4h21j';

 

How can I put ALL of the characters into an array and access them by $string[0], $string[1], $string[2], and so on and so on...

 

Basically...exploding the string by..nothing! Regardless of string content (numbers and letters), all individual characters will be put into an array.

 

How can that be done? ;D

Link to comment
Share on other sites

you can actually reference your string as an array in exactly the way you show.

 

$string{2} has been used but I believe in php6 you will only be able to use $string[2] notation.

 

so get the size of the 'array' just use strlen();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.