function mb_str_split($string) {
$length = mb_strlen($string, "utf-8");
$i = 0;
$arr = array();
while ($i < $length) {
$rep = mb_substr($string,$i,1,"utf-8");
array_splice($arr, $i, 1, $rep);
$i++;
}
return $arr;
}
function transcode($string) {
$string = mb_str_split($string);
$string = array_map(function($a) {
$result = unpack('N', mb_convert_encoding($a, 'UCS-4BE', 'UTF-8'));
if (is_array($result) === true) {
return $result[1];
}
}, $string);
return implode("", $string);
}
$string = "аАБВГДЕЁЖЗ";
echo transcode($string);
var products = [
{"id": "1", "name": "Имя1"},
{"id": "2", "name": "Имя2"},
{"id": "3", "name": "Имя3"}
];
var html = '<table>';
var cnt = 0;
for(var i in products) {
if(cnt == 0) {
html += '<tr>';
}
html += '<td>'+products[i]['id']+'</td>' + '<td>'+products[i]['name']+'</td>';
cnt++;
if(cnt == 2) {
cnt = 0;
html += '</tr>';
}
}
if(cnt != 0) {
html += '<td></td><td></td></tr>';
}
html +='</table>';