i try to get the data from the array. My code is:
print_r($result['Header']);
The result is:
header
@LOC = 1,
@USERNAME = Tom,
My problem is: I dont get the @Username for my function. You can see my code above. But i think you guys have a better idea how to solve this easy problem.
I was looking for a solution but i dont get it. @PHP.net i cant find anything with arrays what is similar to my problem. Sorry for my bad english.
Thank you! :)
CodePudding user response:
In this case you can use preg_match_all
to parse data and array_combine
for bind values to variable names:
preg_match_all('/@(\S ) = ([^,] ),/', $result['Header'], $matches);
$vars = array_combine($matches[1], $matches[2]);
print_r($vars);
Result:
Array
(
[LOC] => 1
[USERNAME] => Tom
)