Since phpinfo function returns boolean I was interested to store its output to a variable.
Here is the solution I came up with
ob_start();
phpinfo();
$output = ob_get_clean();
Then we can search in that string everything we want. Hope, this would be helpful for somebody, since I didn't find any solution for this on stackoverflow.