$v ) { if ( !is_numeric($k) ) $k = "'" . addslashes($k) . "'"; $php .= $str . $k . " => " . phpize($v, false, $compact) . ","; } if ( !$compact ) $php = preg_replace("!\n!", "\n\t", $php); $php .= $str . ")"; } elseif ( is_numeric($data) ) $php = addslashes($data); elseif ( is_bool($data) ) $php = $data ? 'true' : 'false'; elseif ( is_null($data) ) $php = "null"; elseif ( is_string($data) ) $php = "'" . implode('\' . "\n" . \'', explode("\n", preg_replace( array('!\\\\!', '!\'!'), array('\\\\\\', '\\\''), $data ))) . "'"; elseif ( $data instanceof PhpizeInterface ) $php = $data->__toPhp($compact); else throw new Exception('Object does not implements PhpizeInterface : ' . get_class($data)); if ( $file ) file_put_contents($file, ""); return $php; } function sprinto( $str, $obj, $default = '') { $a = function ($matches) use ($obj, $default, &$set) { $data = (array) $obj; $path = preg_split('!\.!', $matches[1]); foreach ( $path as $step ) if ( array_key_exists($step, $data) ) $data = $data[$step]; else $data = ''; return $data; return !empty($data) ? $data : ( $default === null ? $matches[0] : $default ); }; return preg_replace_callback("!\{([a-zA-Z0-9_:\-\.]*)\}!", $a, $str); } function joinstr ( $array, $glue = ' ', $start = '', $end = '' ) { if ( $str = implode($glue, $array) ) return $start . $str . $end; return ''; } ?>