$day) { // Skip current day datas if ($date === date('Y-m-d')) continue; $open = $day['1. open']; $high = $day['2. high']; $low = $day['3. low']; $close = $day['4. close']; $volume = $day['5. volume']; $test = $wpdb->get_results($wpdb->prepare("SELECT id FROM wp_financialdata_history WHERE date = %d", [$date]), OBJECT); if (!$test) { $wpdb->insert( 'wp_financialdata_history', [ 'date' => $date, 'open' => $open, 'high' => $high, 'low' => $low, 'close' => $close, 'volume' => $volume ], [ '%s', '%f', '%f', '%f', '%f', '%f', '%d' ] ); } } } function email($email, $subject, $message) { $headers[] = 'From: Groupe LDC '; wp_mail($email, $subject, $message, $headers); }