4
How can I transcript this code in javascript for PHP ?
var temp = "<div class='brick' style='width:{width}px;'><img src='i/photo/{index}.jpg' width='100%'></div>";
var w = 1, h = 1, html = '', limitItem = 49;
for (var i = 0; i < limitItem; ++i) {
w = 1 + 3 * Math.random() << 0;
html += temp.replace(/\{width\}/g, w*150).replace("{index}", i + 1);
}
Sorry if I’m asking a kind of simple question, but I’m a layman in PHP.
You can optimize and kill some variables, but since you did not give details, I did similar to the original.
– Bacco