// 1
if (empty($arr[$id])) {
$arr[$id] = $id;
}
// 2
if (!in_array($id, $arr)) {
$arr[] = $id;
}
toxa@acer:mylib.acer$ php bin/cli.php websocket runner client btcusdt aggTrade
[2022-05-22 12:28:59] 0.4Mb | [2022-05-22 12:28:59] Start websocket runner client
[2022-05-22 12:29:00.954361] BTCUSDT | Price: 29588.430000 | Quantity: 0.013
[2022-05-22 12:29:01.577557] BTCUSDT | Price: 29588.420000 | Quantity: 0.001
[2022-05-22 12:29:01.712629] BTCUSDT | Price: 29588.420000 | Quantity: 0.004
[2022-05-22 12:29:01.918114] BTCUSDT | Price: 29588.420000 | Quantity: 0.001
[2022-05-22 12:29:02.803572] BTCUSDT | Price: 29588.430000 | Quantity: 0.001
[2022-05-22 12:29:03.644207] BTCUSDT | Price: 29588.430000 | Quantity: 0.035
[2022-05-22 12:29:03.837587] BTCUSDT | Price: 29588.420000 | Quantity: 0.001
[2022-05-22 12:29:04.235999] BTCUSDT | Price: 29588.430000 | Quantity: 0.004
[2022-05-22 12:29:04.569596] BTCUSDT | Price: 29588.430000 | Quantity: 0.002
[2022-05-22 12:29:05.357045] BTCUSDT | Price: 29588.430000 | Quantity: 0.004
[2022-05-22 12:29:05.369365] BTCUSDT | Price: 29588.420000 | Quantity: 0.004
[2022-05-22 12:29:05.725119] BTCUSDT | Price: 29588.430000 | Quantity: 0.004
[2022-05-22 12:29:06.057697] BTCUSDT | Price: 29588.420000 | Quantity: 0.012
[2022-05-22 12:29:06.242477] BTCUSDT | Price: 29588.430000 | Quantity: 0.040
[2022-05-22 12:29:06.422140] BTCUSDT | Price: 29588.420000 | Quantity: 0.009
[2022-05-22 12:29:06.591164] BTCUSDT | Price: 29588.430000 | Quantity: 0.000
[2022-05-22 12:29:06.819583] BTCUSDT | Price: 29588.430000 | Quantity: 0.000
[2022-05-22 12:29:07.135043] BTCUSDT | Price: 29588.430000 | Quantity: 0.002
[2022-05-22 12:29:07.208470] BTCUSDT | Price: 29588.430000 | Quantity: 0.000
[2022-05-22 12:29:07.304731] BTCUSDT | Price: 29588.430000 | Quantity: 0.034
[2022-05-22 12:29:07.424269] BTCUSDT | Price: 29588.430000 | Quantity: 0.017
[2022-05-22 12:29:07.424867] BTCUSDT | Price: 29588.430000 | Quantity: 0.017
[2022-05-22 12:29:07.640549] BTCUSDT | Price: 29588.420000 | Quantity: 0.023
[2022-05-22 12:29:07.725336] BTCUSDT | Price: 29588.430000 | Quantity: 0.001
[2022-05-22 12:29:07.774267] BTCUSDT | Price: 29588.430000 | Quantity: 0.001
[2022-05-22 12:29:08.360303] BTCUSDT | Price: 29588.420000 | Quantity: 0.003
[2022-05-22 12:29:09.115353] BTCUSDT | Price: 29588.420000 | Quantity: 0.000
^C
Для борьбы с SQL-инъекциями лучше использовать подготовленные запросы, подробнее:
в mysqli https://www.php.net/manual/ru/mysqli.quickstart.pr...
но мне больше нравиться это в PDO через https://www.php.net/manual/ru/pdostatement.bindval...