Jump to content

Text string to array


jonnyenglish89

Recommended Posts

Hey guys

how can i use php to turn a string like this:

 

“A, B#2, C#2, D#3, E”

 

Into an array like this:

 

Array

(

[1] => A

[2] => B

[3] => B

[4] => C

[5] => C

[6] => D

[7] => D

[8] => D

[9]=> E

)

 

I can get the letter and count into an array like this with the help of regex:

Array

(

[A] => 1

=> 2

 [C] => 2

 [D] => 3

 [D]=> 1

)

But I have no idea how I would get the result I desire – any help with this part would be greatly appreciated

Link to comment
Share on other sites

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.