summaryrefslogtreecommitdiff
path: root/includes/inc_utils.php
diff options
context:
space:
mode:
authorAlib <aliboba@free.fr>2010-02-25 13:39:11 +0100
committerAlib <aliboba@free.fr>2010-02-25 13:39:11 +0100
commit0921ec0f64d6782076d1e1fb2333cb53c86d279f (patch)
tree48821410f1eb8332254b46ee22b4d4fce136a426 /includes/inc_utils.php
parentd350aac197f8ad5ab501c3b25b6543e802de0e47 (diff)
downloadistreamdev-0921ec0f64d6782076d1e1fb2333cb53c86d279f.tar.gz
istreamdev-0921ec0f64d6782076d1e1fb2333cb53c86d279f.tar.bz2
trying to debug js array
Diffstat (limited to 'includes/inc_utils.php')
-rwxr-xr-xincludes/inc_utils.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/includes/inc_utils.php b/includes/inc_utils.php
index a984794..541c35b 100755
--- a/includes/inc_utils.php
+++ b/includes/inc_utils.php
@@ -24,4 +24,28 @@ function is_utf8($str) {
}
return true;
}
+
+function php2js ($var) {
+ if (is_array($var)) {
+ $res = "[";
+ $array = array();
+ foreach ($var as $a_var) {
+ $array[] = php2js($a_var);
+ }
+ return join(",", $array);
+ }
+ elseif (is_bool($var)) {
+ return $var ? "true" : "false";
+ }
+ elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
+ return $var;
+ }
+ elseif (is_string($var)) {
+ return "\"" . addslashes(stripslashes($var)) . "\"";
+ }
+ // autres cas: objets, on ne les gère pas
+ return FALSE;
+}
+
+
?>