$x = "4.43";
$y = "24.8500";
$result = floatval($x) * floatval($y);
echo $result;
private function request($method, array $params)
{
$params['v'] = $this->v;
$ch = curl_init('https://api.vk.com/method/' . $method . '?access_token=' . $this->token);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data, true);
//print_r($json);
if (!isset($json['response'])) {
// throw new \Exception($data);
return $json;
}
return $json['response'];
}
private function replaceColor($color)
{
switch ($color) {
case 'red':
$color = 'negative';
break;
case 'green':
$color = 'positive';
break;
case 'white':
$color = 'default';
break;
case 'blue':
$color = 'primary';
break;
}
return $color;
}
public function GenerateKeyboard($buttons = [], $one_time = False)
{
$keyboard = [];
$i = 0;
foreach ($buttons as $button_str) {
$j = 0;
foreach ($button_str as $button) {
$color = $this->replaceColor($button[2]);
$keyboard[$i][$j]["action"]["type"] = "text";
if ($button[0] != null)
$keyboard[$i][$j]["action"]["payload"] = json_encode($button[0], JSON_UNESCAPED_UNICODE);
$keyboard[$i][$j]["action"]["label"] = $button[1];
$keyboard[$i][$j]["color"] = $color;
$j++;
}
$i++;
}
$keyboard = ["one_time" => $one_time,
"buttons" => $keyboard];
$keyboard = json_encode($keyboard, JSON_UNESCAPED_UNICODE);
return $keyboard;
}