Hey all:
Just started playing with PHP, and ran into a little problem. I'm
writing a script that will extract the strings from a binary file, then
parse through them and extract information:
<?php
$data = file_get_conten ts('./dicomdir');
preg_match_all( '/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($my List[0]);
print $substr . "\n";
}
?>
This works fine, and basically emulates the "strings" command from the
binutils package. Sample output in my test case:
DICM
1.2.840.10008.1 .3.10
1.2.826.0.1.368 0043.2.287.192. 168.1.3.3346521 .984187648748.3 2768
1.2.840.10008.1 .2.1
1.2.826.0.1.368 0043.2.287.0.11 3
SHS_MV300_VA30A
PACSCUBE
PACSCUBE MEDIA
PATIENT
DOE-^JANE
68682
19340928
I want to look for the word 'PATIENT', the assign the next word to a
variable, so I tried this:
<?php
$data = file_get_conten ts('./dicomdir');
preg_match_all( '/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($my List[0]);
if ($substr == 'PATIENT'){
$patient_name = array_shift($my List[0]);
print $patient_name;
}
}
?>
This does not work as expected. Any ideas?
-cjl
Just started playing with PHP, and ran into a little problem. I'm
writing a script that will extract the strings from a binary file, then
parse through them and extract information:
<?php
$data = file_get_conten ts('./dicomdir');
preg_match_all( '/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($my List[0]);
print $substr . "\n";
}
?>
This works fine, and basically emulates the "strings" command from the
binutils package. Sample output in my test case:
DICM
1.2.840.10008.1 .3.10
1.2.826.0.1.368 0043.2.287.192. 168.1.3.3346521 .984187648748.3 2768
1.2.840.10008.1 .2.1
1.2.826.0.1.368 0043.2.287.0.11 3
SHS_MV300_VA30A
PACSCUBE
PACSCUBE MEDIA
PATIENT
DOE-^JANE
68682
19340928
I want to look for the word 'PATIENT', the assign the next word to a
variable, so I tried this:
<?php
$data = file_get_conten ts('./dicomdir');
preg_match_all( '/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($my List[0]);
if ($substr == 'PATIENT'){
$patient_name = array_shift($my List[0]);
print $patient_name;
}
}
?>
This does not work as expected. Any ideas?
-cjl
Comment