const divider = '-';
const symbol = 'x';
let x = symbol;
let prefix = divider;
let suffix = divider;
for (let i = 0; i < 2; i++) {
prefix += x + divider;
suffix = divider + x + suffix;
x += symbol;
}
let result = prefix + x + suffix;
console.log(result);
const x = () => 42;
const x = () => {return 42;}
<!--KARUSEL-->
.$karusel_HTML = file_get_contents("./karusel.html");
$html = str_replace("<!--KARUSEL-->", $karusel_HTML, $html);
<a href="#"/>
там, где должен быть <button/>
, вы уже сделали половину семантики страницы. -window.addEventListener('DOMContentLoaded', () => {
+document.addEventListener('DOMContentLoaded', () => {
Стоит ли хранить изображения base64 в БД?
composer require symfony/dom-crawler
use Symfony\Component\DomCrawler\Crawler;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\File;
$desc = $request->input('some_html'); // POST with html
$dom_desc = new Crawler($desc);
$images = $dom_desc->filterXPath('//img')->extract(array('src')); // extract images
foreach ($images as $key => $value) {
if (strpos($value, 'base64') !== false) { // leave alone not base64 images
$data = explode(',', $value); // split image mime and body
$tmp_file = tempnam('/tmp', 'items'); // create tmp file path
file_put_contents($tmp_file, base64_decode($data[1])); // fill temp file with image
$path = Storage::putFile('public/items', new File($tmp_file)); // put file to final destination
$desc = str_replace($value, $path, $desc); // replace src of converted file to fs path
unlink($tmp_file); // delete temp file
}
}