note 31757 added to function.highlight-file

From: Date: Fri, 02 May 2003 17:06:41 +0000
Subject: note 31757 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-47389@lists.php.net to get a copy of this message
Hi! Here is a simple script for extracting all strings from the source code. Although it ignores special escape sequences in the strings, it may be useful. #!/usr/bin/php <?php $data = highlight_file($argv[1], true); $p = xml_parser_create(); $data = str_replace('&nbsp;', ' ', $data); xml_parse_into_struct($p, $data, $vals, $index) || die(xml_error_string(xml_get_error_code($p))); xml_parser_free($p); foreach ($vals as $val) { if ($val['tag'] == 'FONT' && $val['type'] == 'complete' && $val['attributes']['COLOR'] == ini_get('highlight.string')) { $a = $val['value']{0}; $b = $val['value']{$val['value'] - 1}; echo ($a == $b && $a == '"' || $a = "'") ? substr($val['value'], 1, strlen($val['value']) - 2) : $val['value']; echo "\n"; } } -- http://www.php.net/manual/en/function.highlight-file.php http://master.php.net/manage/user-notes.php?action=edit+31757 http://master.php.net/manage/user-notes.php?action=delete+31757 http://master.php.net/manage/user-notes.php?action=reject+31757

« previous php.notes (#47389) next »