PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I turn a string into an array?


Interchange between strings and arrays is very common in PHP even for use on websites and manipulating data to be sent, or sent, from the webpage.

To do this you can use the explode function, like this, passing the delimiter to explode on as the first argument and the string as the second:

<?php
$mystring 
"I,love,washing,up";
$myarray explode(",",$mystring);
print_r($myarray);
?>


Which gives us this:

Array
(
[0] => I
[1] => love
[2] => washing
[3] => up
)



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

How do I break email address into username and hostname?

How do I remove trailing whitespace from a string?

How do I one-way encrypt a string in PHP?

print(1 . " + " . 2 . " = " . 1+2 . "n"); gives answer 3 why?

How do you hash the password in this php script: define(sb db user name, admin store); define(sb db password, mypassword);



Custom Search