note 108247 deleted from function.get-defined-functions by mazzanet
| From: | mazzanet@php.net | Date: | Thu, 12 Apr 2012 06:12:28 +0000 |
| Subject: | note 108247 deleted from function.get-defined-functions by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187080@lists.php.net to get a copy of this message | ||
Note Submitter: lukepress at web dot de
----
list of user-defined function from file (in Array)
with function + name only + arguments (as sub-Array)
<?php
// -----------------------------------------------------
$content = file_get_contents('functions.php');
$pattern = '/function (.*?){/';
preg_match_all($pattern, $content, $matches);
// ------------------------------------
$i=0;
foreach($matches[1] as $match) {
$match = trim(chop($match));
$erg[$i]['function'] = $match;
$funcname = explode('(',$match);
$erg[$i]['funcname'] = trim($funcname[0]);
$argstr = strrchr($match,'(');
$argstr = str_replace(array('(',')','
'),array('','',''),$argstr);
$argarr = explode(',',$argstr);
$erg[$i]['funcargs'] = $argarr;
$i++;
}
// ------------------------------------
print "<pre>\n";
print_r($erg);
print "</pre>\n";
// -----------------------------------------------------
?>
Example Output:
Array
(
[0] => Array
(
[function] => convertTag($tag, $direction = 'out')
[funcname] => convertTag
[funcargs] => Array
(
[0] => $tag
[1] => $direction='out'
)
)
[1] => Array
(
[function] => filter($data, $type = NULL)
[funcname] => filter
[funcargs] => Array
(
[0] => $data
[1] => $type=NULL
)
)
)