Jump to content
WesleyA

more ways converting string into an array?

Recommended Posts

I want to transfer a string (several values ) into a php array. I know explode is used to do that. But is explode the only way or are there other ways to do this in php?

Share this post


Link to post
Share on other sites

It depends on what rules you want to use to convert the string into an array. There's str_split() if you want to break the string into equally sized array pieces, preg_split() works like explode() except that it uses a regular expression as the delimiter.

 

If you tell us what exactly you're trying to do with the string then we can be more specific with how to turn it into an array.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...