<?php
$s = "Один Два Три Четыре Пять Длинноеслово";
$pos = 0;
$maxLen = 10;
$res = [];
while($pos < mb_strlen($s)){
while(mb_substr($s,$pos,1) == " ")
$pos++;
$v = mb_substr($s,$pos,$maxLen);
if($pos+$maxLen <= mb_strlen($s)-1 && mb_substr($s,$pos+$maxLen,1) == " ")
$v = mb_substr($s,$pos,$maxLen+1);
$nextPos = mb_strrpos($v," ");
if($nextPos != null && $pos+$maxLen < mb_strlen($s)-1){
array_push($res,mb_substr($v,0,$nextPos));
$pos+= $nextPos;
}
else{
$pos+= mb_strlen($v);
array_push($res,$v);
}
}
var_dump($res);
array(5) {
[0]=>
string(15) "Один Два"
[1]=>
string(19) "Три Четыре"
[2]=>
string(8) "Пять"
[3]=>
string(20) "Длинноесло"
[4]=>
string(4) "во"
}
let arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3];
var seed = 12837823631;
arr = arr.sort((a,b)=>rand() - rand());
function rand(){
seed = (45 * seed + 21) % 67;
return seed/67;
}
let arr = ["genre","type","long","country","awards","result","actor"];
arr.forEach((c)=>{
document.querySelector(`#category-${c}`).addEventListener('click', () => {
document.querySelector(`#subcategory-block-${c}`).classList.toggle('active');
document.querySelector(`#menu-figure-${c}`).classList.toggle('activeForMenuFigure');
})
});
var time = "10:25";
var duration = 1232 ;
const hour = Math.floor(duration / 60);
const min = duration - hour * 60;
let hs = parseInt(time.split(":")[0]);
let ms = parseInt(time.split(":")[1]);
let he = (hs + hour + Math.floor((min+ms)/60))%24;
let me = (min+ms)%60;
alert(`${hour}:${min} - ${he}:${me}`)
function checkParams() {
var name = $('#name').val();
var email = $('#email').val();
var phone = $('#phone').val();
if(name.length != 0 && email.length != 0 && phone.length != 0 && $('#personaldata').prop("checked") && ($('#cakecheck').prop("checked") || $('#drinkcheck').prop("checked")))
$('#submit').removeAttr('disabled');
else
$('#submit').attr('disabled', 'disabled');
}
function addProductView(id){
let lastProducts = [];
try{
lastProducts = localStorage.getItem("last_products");
if(lastProducts == null)
lastProducts = [];
else
lastProducts = JSON.parse(lastProducts);
}catch(e){
lastProducts = [];
}
lastProducts = lastProducts.filter(e=>e.id !=id);
lastProducts.push({
date:Date.now(),
id:id
});
localStorage.setItem("last_products",JSON.stringify(lastProducts.sort((c,n)=>n.date - c.date).splice(0,20)));
}
function getLastViews(){
let lastProducts = [];
try{
lastProducts = localStorage.getItem("last_products");
if(lastProducts == null)
lastProducts = [];
else
lastProducts = JSON.parse(lastProducts);
}catch(e){
lastProducts = [];
}
return lastProducts.sort((c,n)=>n.date - c.date).map(e=>e.id);
}
Thread thread = new Thread(() => {
unt_client_recv(client, "127.0.0.1", 25443);
});