Go to the documentation of this file.00001 <?php
00023 function array_safe_filter (array &$array, array $exclude = array()) {
00024 $exclude = array_merge(array(null, false, ""), $exclude);
00025 foreach ($array as $key => $value) {
00026 if (in_array($value, $exclude, true))
00027 unset($array[$key]);
00028 }
00029 }
00030
00045 function callback ($fct) {
00046 if (!preg_match('~(function)?\s*\((?P<args>[^\)]*)\)\s*\{(?P<code>.*)\}~', $fct, $matches))
00047 return false;
00048
00049 $args = $matches['args'];
00050 $code = $matches['code'];
00051 return create_function($args, $code);
00052 }
00053
00062 function array_cartesian_product () {
00063 if (!$c = func_num_args())
00064 return array();
00065
00066 if ($c == 1) {
00067 foreach ((array)func_get_arg(0) as $v)
00068 $r[] = (array)$v;
00069 return $r;
00070 }
00071
00072 $a = func_get_args();
00073 $f = array_shift($a);
00074 $s = call_user_func_array(__FUNCTION__, $a);
00075
00076 foreach ((array)$f as $v) {
00077 foreach ($s as $w) {
00078 array_unshift($w, $v);
00079 $r[] = $w;
00080 }
00081 }
00082
00083 return $r;
00084 }