/**
* wrap
*
* Creates a wrapper around a function and returns the wrapper as a function.
* @param $fnc.
* @return function.
* Credit:
* http://www.andyhsoftware.co.uk/space
* http://www.thescripts.com/forum/thread9037.html
* Example usage:
* function times($a,$b){
*$a * $b;
* }
* $dbl = wrap('times',2);
* echo '450 doubled is ' . $dbl(456);
*/
function fnc_wrap($fnc) {
$args = func_get_args();
array_shift($args);
$lambda = sprintf(
'$args = func_get_args(); ' .
'return call_user_func_array(\'%s\', array_merge(unserialize(\'%s\'),$args));',$fnc, serialize($args));
return create_function('', $lambda);
}
PHP and javascript snippets you can copy and paste.
Blog Archive
-
▼
2007
(71)
-
▼
March
(25)
- net_get_HTMLDescriptionFromCode($HTMLCode)
- net_increment_ipAddress($iPAddress)
- sec_remove_emailInjectionChars($str)
- str_get_textBetween($start,$end,$str)
- str_remove_doubleQuotes($str)
- str_remove_Quotes($str)
- ajax request
- str_remove_singleQuotes($str)
- str_explode_strAssoc($separator,$assignSeparator,$...
- str_get_strlenmb($s)
- str_get_substrmb($s,$start,$len)
- ajx_print_r
- str_remove_strFromStart($needle,$haystack)
- file_write($fileName, $data, $mode)
- net_get_remoteFile($path,$method='GET',$timeout=30)
- str_get_pointsBetween($start,$end,$s,$n=0)
- dir_do_dirIteratorCallback($dir,$fn,$params)
- fnc_conv_argsToArray()
- net_conv_urlStringToArray($urlStr)
- net_conv_arrayToURLStr($arr,$prefix,$arg_separator)
- xml_get_isXML($xml)
- str_get_strMatchesEnd($needle,$haystack)
- str_conv_strToLowerCaseArray($separator,$s)
- fnc_wrap($fnc)
- net-get-randomIP()
-
▼
March
(25)