How to split a variable into an array

1

My question is a bit complex, which I will try to explain.

I have a php variable, which always returns results as follows:

"8017990310062\r8017990142064\r801792340068\r"

What I want to do is "rearrange" the displayed numbers of the variable and assign it in an array, that is, first of all I want to get the quotes from the variable, then remove the \ re and then pick up the numbers and each array has a number.

Example:

$array[0] = 8017990310062;
$array[1] = 8017990142064;
$array[2] = 801792340068;

Note that my variable can have more than 3 values, such as 5 , 7 or 8 .

How can I do this?

    
asked by anonymous 20.12.2016 / 14:00

1 answer

2

Do this:

$var = "8017990310062\r8017990142064\r801792340068\r";

$varRep = str_replace('"', '', $var);
$varExp = explode('\r', $varRep);
    
20.12.2016 / 14:05