<?php

/*

$file = '{ "message-count": "1", "messages": [{ "to": "385914900075", "message-id": "2B00000014908089", "status": "0", "remaining-balance": "172.35570000", "message-price": "0.04620000", "network": "21910" }] }';

$data_arr = json_decode($file);

print_r($data_arr);

echo $data_arr -> messages[0] -> {'message-id'};
echo $data_arr -> {'message-count'};

// ako ima da je poslana poruka, da je više od 1
if ($data_arr -> {'message-count'} > 0) {
	if ($data_arr -> messages[0] -> status == "0") {
		// poruka je poslana!!!!
	} else {
		// poruka nije poslana!!!
	}
} else {
	// poruka nije poslana!!!!
}
*/

/*

$cf_agents = array("1" => array("nexmo", "from" => "614800494421"), "2" => array("nexmo", "from" => "614800494422"), "3" => array("nexmo", "from" => "614800494423"), "4" => array("nexmo", "from" => "614800494424"), "5" => array("nexmo", "from" => "614800494425"), "6" => array("nexmo", "from" => "614800494426"));

function pushSMS($ag, $to, $msg, $msg_id) {
	global $cf_agents, $cf_api_key, $cf_api_secret;
	// get name of the function depending on current ag!
	switch($cf_agents[$ag][0]) {
		case "nexmo":
			nexmo($cf_api_key, $cf_api_secret, $cf_agents[$ag]["from"], $to, $msg, $msg_id)
		break;
	}
	echo $cf_agents[$ag][0]."----".$cf_agents[$ag]["from"];
}
*/

//pushSMS($_GET["ag"], 1, 1, 1);

/*
date_default_timezone_set('Europe/Zagreb');

if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />1';
}

if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone'). '<br />1';
}
*/

$string = "1 => Mag .. this is taking far to long now I'm very frustrated with it a|||2 => ll .. there's things going on where I live + it's not good I need t|||4 => his up :smiley:|||3 => o move on .. have U any idea how long now ? Mentally I can't keep t";
$string2 = "String gdje ne postoji trala lalalala";

if(preg_match("/=>/", $string) && preg_match("/\|{3}/", $string) ) {
	$my_array = explode("|||", $string);
	$output_array = array();
	$output_string = "";
	foreach($my_array as $value) {
		$temp_array = explode("=>", $value);
		$output_array[trim($temp_array[0])] = trim($temp_array[1]);
	}
	ksort($output_array);
	foreach($output_array as $key => $value) {
		$output_string .= $value;
	}
	return $output_string;
} else {
	return $string;
}


SELECT * FROM messages WHERE mess_client_id = 502 order by mess_date DESC; 
?>