fgets() shows output is as below =
string(10) "1236457" string(8) "xyz" string(15) "credit:87845 " string(17) "balance:644546 " string(17) "remaining:7463847"
i want to store $var1=1236457 $var2= xyz and same for all.But without using explode.
fgets() shows output is as below =
string(10) "1236457" string(8) "xyz" string(15) "credit:87845 " string(17) "balance:644546 " string(17) "remaining:7463847"
i want to store $var1=1236457 $var2= xyz and same for all.But without using explode.
If you insist on having variables you can iterate the array and create associative keys and then use extract to create the variables.
In this example I use 0 indexed lines, meaning first line is $line0.
$arr = explode("
", $str);
Foreach($arr as $key => $val){
$new["line" . $key] = $val;
}
Extract($new);
Echo $line2;