Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate elements in an array?
<?
include('config.php');
$link = mysql_connect($config[host], $config[db_user], $config[db_pass])
or die("Could not connect: " . mysql_error());
mysql_select_db($config[db_name]);
mysql_set_charset('utf8');
$xml_currency = mysql_query("SELECT * FROM `currency` WHERE `status` = '1' ");
while($xml_currency_row = mysql_fetch_assoc($xml_currency)){
$cy[] = array("name_xml" => $xml_currency_row[xml_k],"type" => $xml_currency_row[com_type],"id" => $xml_currency_row[id],"rez"=> $xml_currency_row[reserve], "stavka" => $xml_currency_row[com]);
}
$dir_sql = mysql_query("SELECT * FROM `direction` WHERE `give` = '12' AND `status` = '1' ");
while($dir_row = mysql_fetch_assoc($dir_sql))
{
$float = number_format($dir_row['get_course'], 4, '.', '');
$float1 = number_format($dir_row['give_course'], 4, '.', '');
$lol['1'][$dir_row['get']] = array( 'in_min_amount' => floatval($dir_row[min_amount]));
if($float1 > '1')
{
$lol['1'][$dir_row['get']]['in'] =round($float1,4);
}
else if($float1 < 1)
{
$t = 1 / $float1;
$lol['1'][$dir_row['get']][out] =round($t,4);
}
if($float > '1')
{
$lol['1'][$dir_row['get']][out] =round($float,4);
}
else if($float < 1)
{
$t1 = 1 / $float;
$lol['1'][$dir_row['get']][out] =round($t1,4);
}
$cy_dir = array("to" => $lol['1']);
}
echo json_encode(($cy_dir),JSON_PRESERVE_ZERO_FRACTION );
?>
{"to":{"10":{"in_min_amount":0.01,"out":7050.18},"11":{"in_min_amount":0.01,"out":7012.31},"13":{"in_min_amount":0.01,"out":13.09},"20":{"in_min_amount":0.01,"out":226523.9172},"18":{"in_min_amount":0.15,"out":7350.4542},"16":{"in_min_amount":0.0075,"out":6811.87}}}
Answer the question
In order to leave comments, you need to log in
What is the criterion for repeating array elements? Should two array elements be exactly equal, or only one of the element fields?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question