Jump to content

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
https://forums.phpfreaks.com/topic/305956-text-string-to-array/
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.