1

I'm trying to convert data from one text input (form) into an array so I can run a loop on that array.

The user input should be a list of words (ex: phone email message) separated by space. I want to insert that data into an array ([0] phone [1] email [2] message) and kinda stuck doing that.

Any suggestions how to do that?

Thanks in advance

1 Answer 1

1

Assuming your input is in a variable called $input, you can create an array of the words (separated by space) by using explode():

$array = explode(' ', $input);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.