note 93274 modified in function.highlight-file by danbrown
| From: | danbrown@php.net | Date: | Tue, 01 Sep 2009 03:33:14 +0000 |
| Subject: | note 93274 modified in function.highlight-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160110@lists.php.net to get a copy of this message | ||
Just my two cents - a function that takes PHP source code from a file and decodes it to text/plain
MIME-type.
Cheers,
Joel A. Villarreal Bertoldi
<?php
function phps2array($fileName)
{
return explode("\r", html_entity_decode(strip_tags(highlight_file($fileName, true))));
}
?>
Example:
####################################
samplefile.php:
<?php
$a = 1;
/* This is my file*/
echo $a;
?>
parser.php:
<?php
header("Content-Type: text/plain");
print_r(parse_php_file("samplefile.php"));
?>
####################################
Results:
####################################
Array
(
[0] => <?php
[1] => $a = 1;
[2] =>
[3] => /* This is my file*/
[4] => echo $a;
[5] => ?>
)
####################################
--was--
Just my two cents - a function that takes PHP source code from a file and decodes it to text/plain
MIME-type.
Cheers,
Joel A. Villarreal Bertoldi
####################################
function phps2array($fileName)
{
return explode("\r", html_entity_decode(strip_tags(highlight_file($fileName, true))));
}
####################################
Example:
####################################
samplefile.php:
<?php
$a = 1;
/* This is my file*/
echo $a;
?>
parser.php:
<?php
header("Content-Type: text/plain");
print_r(parse_php_file("samplefile.php"));
?>
####################################
Results:
####################################
Array
(
[0] => <?php
[1] => $a = 1;
[2] =>
[3] => /* This is my file*/
[4] => echo $a;
[5] => ?>
)
####################################
http://php.net/manual/en/function.highlight-file.php