Fatemeh Namkhah
Fatemeh Namkhah

Reputation: 711

how to convert integer array to separated numbers in php

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

Upvotes: 1

Views: 54

Answers (2)

Muhammad Bilal
Muhammad Bilal

Reputation: 2134

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

Upvotes: -1

Paladin
Paladin

Reputation: 1637

You have tried "list"?

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

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

Upvotes: 4

Related Questions