Reputation: 19
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.
Upvotes: 0
Views: 105
Reputation: 23958
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("\n", $str);
Foreach($arr as $key => $val){
$new["line" . $key] = $val;
}
Extract($new);
Echo $line2;
Upvotes: 1