<?php
// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting,
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds.
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------
function json_encode($arr) {
$json_str = '';
if(is_array($arr))
{
$pure_array = true;
$array_length = count($arr);
for($i=0;$i<$array_length;$i++)
{
if(! isset($arr[$i])){
$pure_array = false;
break;
}
}
if($pure_array){
$json_str ='[';
$temp = array();
for($i=0;$i<$array_length;$i++) $temp[] = json_encode($arr[$i]);
$json_str .= implode(',',$temp);
$json_str .=']';
}
else
{
$json_str ="{";
$temp = array();
foreach($arr as $key => $value){
$temp[] = sprintf('"'.$key.'":'.json_encode($value));
}
$json_str .= implode(",",$temp);
$json_str .="}";
}
}
else{
if(is_string($arr)) $json_str = '"'.$arr. '"';
elseif(is_numeric($arr)) $json_str = $arr;
else $json_str = '"'.$arr. '"';
}
return $json_str;
}
?>