1

What would be the most simple way to convert an Array Integer to separate numbers?

Example:

array(2,4,6)

should result in:

num1=2,num2=4,num3=6

3
  • So have you tried anything??? Commented Sep 7, 2015 at 7:23
  • use a loop like for() to get your numbers Commented Sep 7, 2015 at 7:24
  • Why can't you use the array as is? Commented Sep 7, 2015 at 7:36

2 Answers 2

4

You have tried "list"?

list($num1, $num2, $num3) = $myArray;

See http://php.net/list for more details.

Sign up to request clarification or add additional context in comments.

Comments

-1

If you have associative array than You can use php built in function extract().

Example:

$abc = array('var1'=>2, 'var2'=>4, 'var3'=>6);
extract($abc);
echo $var1.$var2.$var3; //Outputs 246

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.