分解数组值并分配给变量

I have an array as shown here

25|12|3|53

I want to break and store the values in the array on to variables as shown below.

$variable1 = 25
$variable2 = 12
...

Any suggestions would be appreciated

Certainly that is possible:

<?php
$input = [25,12,3,53];
foreach ($input as $key => $val) {
  $varname = 'var' . ($key+1);
  $$varname = $val;
}
var_dump([$var1, $var2, $var3, $var4]);

The output obviously is:

array(4) {
  [0]=>
  int(25)
  [1]=>
  int(12)
  [2]=>
  int(3)
  [3]=>
  int(53)
}

To do exactly as you asked:

$array = array(25, 'another', 'yet another', 'value');
foreach($array as $index => $value)
{
     ${'variable' . ++$index} = $value;
}

echo $variable1; //shows 25

you can use bracket { } to create new variable from variable

foreach ($array as $i => $arr)
{
  ${'variable'.$i+1} = $arr;
}

Taking the elements of an array into variables only makes sense, if you have a specific number of elements, so you can work with that distinct set of variables in your code. In all other cases you should go on to work with arrays instead.

Because of that, this answer assumes, that your array has a distinct set of elements. In that case you can use list() to transform the elements into variables:

$array = [12, 25, 3, 53];

list($value1, $value2, $value3, $value4) = $array;

echo $value1; // echoes 12
echo $value2; // echoes 25
echo $value3; // echoes 3
echo $value4; // echoes 53

With PHP 7.1 and higher the following short code can be used aswell:

$array = [12, 25, 3, 53];

[$value1, $value2, $value3, $value4] = $array;

echo $value1; // echoes 12
echo $value2; // echoes 25
echo $value3; // echoes 3
echo $value4; // echoes 53