$dizi=array();
$a=2;
$dizi[]= $a;
$dizi[]= 4;
$dizi[]= 7;
Array ( [0] => 2 [1] => 4 [2] => 7 )
how can i assing to variable like :
$variable=247
$dizi=array();
$a=2;
$dizi[]= $a;
$dizi[]= 4;
$dizi[]= 7;
Array ( [0] => 2 [1] => 4 [2] => 7 )
how can i assing to variable like :
$variable=247
You can implode an array on a delimiter. If you provide no delimiter, it concatenates all the values together.
$variable = implode('',$dizi);
Outputs: $variable = 247;
make a variable and set it equal to `implode("", $array); now if you echo the variable the result will be values of array without space or line-break.
$dizi=array();
$a=2;
$dizi[]= $a;
$dizi[]= 4;
$dizi[]= 7;
$variable = implode("", $dizi);
echo $variable;
The implode() function returns a string from the elements of an array.
$variable = implode("", $dizi);
Output
$variable=247
You can also try the join function.
The join() function returns a string from the elements of an array.
$variable = join("", $dizi);
Output
$variable=247
The join() function is an alias of the implode() function.
Though implode is the best way, i have tried using json_encode
$variable=str_replace(array('[', ']',','), '', json_encode($dizi));
Outputs: $variable = 247;