<?php
$dates = [
'28.06.2024',
'29.06.2024',
'30.06.2024',
'01.07.2024',
'02.07.2024',
'03.07.2024',
'04.07.2024'
];
$names = [
'28.06.2024' => ['Петров Петр Петрович', 'Петров Петр Петрович'],
'03.07.2024' => ['Петров Петр Петрович', 'Иванов Иван Иванович', 'Петров Петр Петрович', 'Иванов Иван Иванович'],
'02.07.2024' => ['Петров Петр Петрович', 'Иванов Иван Иванович'],
'01.07.2024' => ['Иванов Иван Иванович', 'Петров Петр Петрович', 'Иванов Иван Иванович'],
'26.06.2024' => ['Петров Петр Петрович', 'Петров Петр Петрович'],
'04.07.2024' => ['Иванов Иван Иванович']
];
$strangeTask = new StrangeTask($names);
$allNames = $strangeTask->getNames();
foreach ($dates as $date) {
foreach ($allNames as $name) {
echo $strangeTask->getNameOnDate($date, $name);
}
}
class StrangeTask
{
public function __construct(public array $names)
{
}
public function getNameOnDate(string $date, string $name): ?string
{
if (!isset($this->names[$date])) {
return null;
}
return in_array($name, $this->names[$date]) ? $name : null;
}
public function getNames(): array
{
$names = [];
array_walk_recursive($this->names, function ($v) use (&$names) {
$names[$v] = $v;
});
return $names;
}
}
<?php
$name = trim(stripslashes($_POST['name']));
$from = trim(stripslashes($_POST['email']));
$form_message = trim(stripslashes($_POST['message']));
$subject = "Тема письма";
$to = 'daniel.k07@yandex.ru';//replace with your email
$message = "Имя: $name <br> Сообщение: $form_message";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, implode("\r\n", $headers));
die;
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
dataType: 'json',
method: "POST",
data: {
message : form.children('input[name="message"]').val(),
name: form.children('input[name="name"]').val(),
email: form.children('input[name="email"]').val()
},
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
$i = -1;
foreach ($owned_urls as $k => $v) {
$pos = strpos($v, $string);
if ($pos > 0) $i = $k;
}
if ($i > 0) {
//значение найдено в ячейке, номер которой содержится в $i
} else {
//значение не найдено
}
$str = implode(",", $owned_urls);
$pos = strpos($str, $string);
if ($pos > 0) {
//значение найдено
} else {
//значение не найдено
}
if( isset($_REQUEST["action"]) ) $action = str_replace('.', '', $_REQUEST["action"]);
else die(json_encode(array('success' => false, 'errors' => 'Ошибка! Попробуйте еще раз!')));
$functions = new functions();
if ( $functions->$action() ) echo $functions->data;
else echo json_encode(array('success' => false, 'errors' => ''));
class functions {
public $data;
function f1() {
//тут какой-то код вашей функции
$this->data = json_encode(array('success' => true));
return true;
}
}
$data = [];
foreach ($_POST['hours'] as $k => $v) {
if ( $v != '' AND $v != 0 ) {
$res = [];
$res['hours'] = $v;
$res['fio']= $_POST['fio'][$k];
$res['mestoRaboty']= $_POST['mestoRaboty'][$k];
$res['dogovor']= $_POST['dogovor'][$k];
$res['object']= $_POST['object'][$k];
$res['vidarb']= $_POST['vidarb'][$k];
$res['date']= $_POST['date'][$k];
$data[] = $res;
}
}
<script type="text/javascript">
$(document).ready(function(){
$('.checkbox').on('change', function (e) {
var chk = $(this).attr("id");
if($(this).is(':checked')) {
$(this).parent().parent().css('background','none');
$(this).val('1');
} else {
$(this).parent().parent().css('background','rgba(0, 123, 255, 0.1)');
$(this).val('0');
}
var chkVal = $(this).attr("value");
$.ajax({
url: '1.php',
type: 'post',
data: {id: chk, chkVal: chkVal },
success: function(data) {}
});
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('.checkbox').on('change', function (e) {
var chk = $(this).attr("id");
var chkVal = $(this).attr("value");
if($(this).is(':checked')) {
$(this).parent().parent().css('background','none');
$(this).val('1');
chkVal = 1;
} else {
$(this).parent().parent().css('background','rgba(0, 123, 255, 0.1)');
$(this).val('0');
chkVal = 0;
}
$.ajax({
url: '1.php',
type: 'post',
data: {id: chk, chkVal: chkVal },
success: function(data) {}
});
});
});
</script>
<?php
$modules = R::findAll('modules', 'id = ?');
$lessons = R::findAll('lessons', 'module_id = ?');
foreach ($modules as $module) {
foreach ($lessons as $lesson) {
if ( $lesson->module_id == $module->id ) {
echo '
<p>Модуль №', ++$i,' | ', $module->name,'</p>
<p>Урок: ', $lesson->name, '</p><br/>
';
}
}
}
?>
select
m.name as `module`,
l.name as `lesson`
from modules m
left join lessons l ON l.module_id = m.id
where l.id is not null
<?php
$file = file('test.txt');
$i = 0;
foreach($file as $line) {
$i++;
$arr = explode(';', $line);
$v = $arr[0];
$ip = $arr[1];
$output = shell_exec("ping $ip -n 1");
$text = iconv("cp866","utf-8", $output);
$pos = strpos($text, "потеряно = 1");
if ( $pos > 0 ) {
echo "<a href='http://$ip:8080' title='$v'>Offline</a><br>";
} else {
if (strlen($text) > 300 ) {
echo "<a href='http://$ip:8080' title='$v'>Online</a><br>";
} else {
echo "<a href='http://$ip:8080' title='$v'>-</a><br>";
}
}
}
?>
require_once ( "../app/core.php" );
// пример роутинга
if ( file_exists("../app/".$module."/conf.php") ) {
require_once ( $module."/conf.php" );
require_once ( "header.php" );
require_once ( $module."/i.php" );
require_once ( "footer.php" );
} else {
require_once ( "404/i.php" );
}
foreach ($data as $elem) {
$selected = ( $id == $elem[id] ? 'selected="selected"' : '' );
$contentCity .= "<option $selected value=\"$elem[id]\">$elem[city]</option>";
}