[eluser]Blue Sapphire[/eluser]
Hi!
I have two custom made helper fucntions. How can I call one custom made helper fucntion in other custom made helper function. Code of two custom made helper functions is below:
Code:
function JEncode($arr){
if (version_compare(PHP_VERSION,"5.2","<"))
{
require_once("JSON.php");
$this->json = new Services_JSON();//instantiate new json object
$data=$this->json->encode($arr); //encode the data in json format
} else
{
$data = json_encode($arr); //encode the data in json format
}
return $data;
}
/***************************************************/
function mCountry(){
$query = $this->db->query('select * from fa_country');
if($query->num_rows() >0)
{
$nbrows = $query->num_rows();
foreach($query->result() as $res){
$rec['id'] = $res->id;
$rec['iso'] = $res->iso;
$rec['name'] = $res->name;
$rec['iso3'] = $res->iso3;
$rec['numcode'] = $res->numcode;
$arr[] = $rec;
}
$jsonresult = JEncode($arr);
echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
//echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
}
I am calling function "JEncode" in second function "mCountry". Am I calling it correctly or not.
Thanks in advance