1

If I want to create an array:

$tem='12,13,14,15';

$arr = array($tem); //which is wrong

Instead of:

$arr = array(12,13,14,15);

How can I do? There's always a syntax error.

1
  • Hi, you can't add multiple entries in that way. Try exploding your string and then running through the resulting array with a foreach loop. Commented Feb 18, 2019 at 19:43

1 Answer 1

2

I'm not sure why you want to do it, anyway:

$tem='12,13,14,15';

$arr = explode(',', $tem);
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.