I believe the format is quite similar to that of the .ini
(of course it has variations, but this is another situation, for the code above I believe it is similar), if it really is similar you can use the parse_ini_string
, of course before it is necessary to make use preg_replace
to remove some things, on specific case I just needed to remove the key quotes, example:
<?php
$regfile = file_get_contents('arquivo.reg');
$regfile = preg_replace('#(\r|\n)"|"(=)#', '$1$2', $regfile);
$parsed = parse_ini_string($regfile, false, INI_SCANNER_RAW);
var_dump($parsed);
An online example: https://ideone.com/ZyHnS0
<?php
$reg = 'Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\leroLero]
"parametro1"=valor
"parametro2"=valor
"parametro3"=valor';
$reg = preg_replace('#(\r|\n)"|"(=)#', '$1$2', $reg);
$parsed = parse_ini_string($reg, true, INI_SCANNER_RAW);
var_dump($parsed);
Will return something like:
Array
(
[parametro1] => valor
[parametro2] => valor
[parametro3] => valor
)
So just compare it like this:
if ($parsed['parametro1'] == 'valor') {
echo 'algo aqui';
}
Note: in case I did not process the sessions, this as false
:
$parsed = parse_ini_string($reg, true, INI_SCANNER_RAW);
but can process using true
if there are more "sessions":
$parsed = parse_ini_string($reg, true, INI_SCANNER_RAW);
Then the result will be: https://ideone.com/wqyzXu
Array
(
[HKEY_LOCAL_MACHINE\SYSTEM\leroLero] => Array
(
[parametro1] => valor
[parametro2] => valor
[parametro3] => valor
)
)
It is a question about PHP itself, want to take the data of . reg and read in a php script? PS: the downvote is not mine.
– Guilherme Nascimento
yes read in PHP and compare in script . with other variables .
– PauloMaia
strange every time I ask question instead of help put negative .....
– PauloMaia
Maybe they were negative because the way the question is a little difficult to understand, I myself had this difficulty at first, there are people who are easy to communicate verbally, but can not do also via internet.
– Guilherme Nascimento
It wants to parse data from a file exported from the windows registry.. the origin of all this came from this post: https://answall.com/questions/226338 and has another very confusing
– Daniel Omine
If it’s an ini file you can start with: How to transform an INI file into an Array?
– rray
is . reg the file !
– PauloMaia