I have an array that named $keys.
The $keys values are:
$keys[0] = "1/7/95"
$keys[1] = "1/7/95"
$keys[2] = "1/7/95"
$keys[3] = "1/7/95"
$keys[4] = "22/7/95"
$keys[5] = "22/7/95"
$keys[6] = "22/7/95"
$keys[7] = "11/7/95"
$keys[8] = "11/7/95"
$keys[9] = "11/7/95"
$keys[10] = "11/7/95"
$keys[11] = "main page"
I need to delete duplicated values in this array. But when I used the array_unique() function the result was:
"1/7/95"
Why?
This is my code, I use this code to make telegram bot keyboard:
$list_product = mysql_query("SELECT * FROM `cart` WHERE `product` = '".$item_group['id']."' AND `status`='0' ");
while($item_type = mysql_fetch_array($list_product))
{
$keys[$j] = array($item_type['detail']);
$j++;
}
$keys[$j] = array('','main page'."\xF0\x9F\x94\x99");
$keys= array_unique($keys,SORT_NUMERIC);
$replyMarkup = array(
'keyboard' => $keys
);
$list_setting = mysql_query("SELECT * FROM `setting` ");
$item_setting = mysql_fetch_array($list_setting);
$encodedMarkup = json_encode($replyMarkup);
$url = 'https://api.telegram.org/bot'.$item_setting['token'].'/sendMessage';
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, "text=".$text_reply."&chat_id=".$user_id."&reply_markup=" .$encodedMarkup);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 500 );
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$check = curl_exec( $ch );
echo('OK!');
But in my bot keyboard I just recieve "1/7/95".
$arr = array_unique($arr);will give you the output:Array ( [0] => 1/7/95 [4] => 22/7/95 [7] => 11/7/95 [11] => main page )