array key exists in php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
if (array_key_exists('btn1', $_POST)) {
button1();
}
if (array_key_exists('btn2', $_POST)) {
button2();
}
function button1()
{
echo 'btn1 is clicked boom!';
}
function button2()
{
echo 'btn2 is clicked wohoo!';
}
?>
<br><br>
<form action="" method="post">
<button name="btn1">click here</button>
<button name="btn2">click here</button>
</form>
</body>
</html>