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_contents('./dicomdir');
preg_match_all('/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($myList[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.3680043.2.287.192.168.1.3.3346521.9841 87648748.32768
1.2.840.10008.1.2.1
1.2.826.0.1.3680043.2.287.0.113
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_contents('./dicomdir');
preg_match_all('/[\x20-x7f]{4,}/', $data, $myList);
while (count($myList[0])) {
$substr = array_shift($myList[0]);
if ($substr == 'PATIENT'){
$patient_name = array_shift($myList[0]);
print $patient_name;
}
}
?>
This does not work as expected. Any ideas?
-cjl