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

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();

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.