$strUtf = iconv('CP1251', 'UTF-8', $str_from_file);
if(mb_strtoupper($str1) == mb_strtoupper($str2))
echo nl2br($String);
<?php
ignore_user_abort(true);
set_time_limit(0);
if (window.screen.width < 1300) {
}
<?php
$parts = array_chunk($all_users->response->profiles, 100);
print_r($parts);
<?php
ini_set('display_errors', 1);
error_reporting(-1);
ini_set('memory_limit', '512M'); //512Mb
//тут ваш код
<?php
// Guestbook, Гостевая книга
if (!is_dir("messages")) {
mkdir("messages");
};
function postMessages() {
foreach (glob('messages/*.txt') as $message) {
$message = file($message);
echo str_replace("\n", "", $message[0]) . "<br/>";
echo str_replace("\n", "", "<a href='mailto:$message[1]'>$message[1]</a>") . "<br/>";
for ($i = 2; $i < sizeof($message); $i++) {
echo htmlspecialchars($message[$i]) . "<br/>";
};
echo "<br/>";
};
};
$messages = scandir("messages");
if (!$_POST) {
postMessages();
//a:
print_form();
} else {
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false && $_POST['author'] && $_POST['email'] && $_POST['message']) {
$author = str_replace("\r\n", "", $_POST['author']);
$email = str_replace("\r\n", "", $_POST['email']);
$msg = $_POST['message'];
$time = (int)(microtime(true) * 1000000);
file_put_contents("messages/$time.txt", "$author
$email
$msg");
} else {
echo 'Error while adding your message.';
//goto a;
print_form();
};
postMessages();
//goto a;
print_form();
};
function print_form()
{
echo
'<form action="index.php" method="post">
<p><input type="text" name="author" required /></p>
<p><input type="text" name="email" required /></p>
<p><textarea name="message" required></textarea></p>
<p><input type="submit" /></p>
</form>';
}
?>
%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu
<?php
$str = 'Здесь ссылка должна быть в теге <a> https://example.ru/ru/task#348141 конец текста';
$re = '%(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}'.
'|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)'.
'(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)'.
'*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?%usi';
$result = preg_replace($re, '<a href="$0" target="_blank">$0</a>', $str);
var_dump($result);
//string(167) "Здесь ссылка должна быть в теге <a> <a href="https://example.ru/ru/task#348141" target="_blank">https://example.ru/ru/task#348141</a> конец текста"
<?php
foreach($data as $k)
{
foreach($k as $kq => $v)
{
foreach(($v["photo_list"]) as $key => $url)
{
$name = (basename($url));
$path = "/".$name;
//если файл существует идём к следующему $url
if(file_exists($path))
{
continue;
}
//скачиваем
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
//записываем
$file = fopen($path, "w+");
fwrite($file, $data);
fclose($file);
}
}
}
SELECT *
использовать SELECT type, lvl, country, isoc
так как лишние данные, это лишние задержки.SELECT ... FROM table WHERE uid IN(uid1, uid2, uidN)
<?php
function draw($array)
{
foreach($array as $item)
{
if(isset($item['CHILD']))
{
echo '<li>'.$item['NAME'].'<ul>';
draw($item['CHILD']);
echo '</ul></li>';
}
else
{
echo '<li>'.$item['NAME'].'</li>';
}
}
}
$arr = [
'CHILD' => [
'16' => [
'NAME' => '1',
'CHILD' => [
'17' => [
'NAME' => 'a'
],
'18' => [
'NAME' => 'b'
]
]
]
]
];
echo '<ul>';
draw($arr['CHILD']);
echo '</ul>';
/*Сохранение результата в промежуточном массиве*/
$orderinfo["goods"] = $items;
/*добавление промежуточного массива в возвращаемый массив*/
$allorders[]=$ordersinfo;
case
('Промо'):
$sql = 'SELECT * FROM promo';
$result = mysqli_query($link, $sql);
$array = array();
while($row = mysqli_fetch_array($result))
{
$item['promo_name'] = $row['promo_name'];
$item['promo_descr'] = $row['promo_descr'];
$item['promo_link'] = $row['promo_link'];
$cod[] = $item;
}
$text = ''; // <---
foreach($cod as $v)
{
$new_line = $v['promo_name'].' - '.$v['promo_descr'].' <a href="'.$v['promo_link'].'">перейти к акции</a><br/>';
if(mb_strlen($text) + mb_strlen($new_line) > 4096) // <---
{
file_get_contents($GLOBALS['api'].'/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text='.urlencode($text));
$text = '';
}
$text .= $new_line; // <---
}
if($text != '') // <---
{
file_get_contents($GLOBALS['api'].'/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text='.urlencode($text));
}
// file_get_contents($GLOBALS['api'] . '/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text=' . urlencode("Код ".$row['promo_name']." \n ".$row['promo_descr']." \n Ссылка ".$row['promo_link']." "));
break;