// исходная строка
$options[$k] = [$row['value']];
// означает то же самое, что
$options[$k] = array($row['value']);
// или
$options[$k][] = $row['value'];
$array = array(
"foo" => "bar",
"bar" => "foo",
);
// Использование синтаксиса короткого массива
$array = [
"foo" => "bar",
"bar" => "foo",
];
let elements = document.getElementsByClassName("menu-link");
let myFunction = function() {
let nodes = this.childNodes;
for (let node of nodes) {
if (node.classList.contains("menu-title")) {
let result = document.getElementById("result");
result.innerText = node.innerText;
}
}
};
for (let i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', myFunction, false);
}
$(".menu-link").click(function() {
$("#result").text($(this).text());
});
SELECT *
FROM `table1` JOIN `table2` ON `title`=`sometitle`
WHERE table1.id NOT IN (SELECT id FROM table3)
ORDER BY `date`
.img img{
width: 650px;
}
.img img{
width: 650px;
img 650px.
.img{
width: 100%;
margin: 0;
padding: 0;
}
}
break outer;
прерываете выполнения цикла, и у вас отрабатывает только элемент array[0][0].let j in i
собрались перебирать? outer: for (let i in array) {
console.log(array[i])
for(let j in array[i]) {
console.log(array[i][j])
if(city === array[0][j]) {
alert('Казахстан')
break outer;
} else if (city === array[1][j]) {
alert('Россия')
break outer;
} else if (city === array[2][j]) {
alert('Китай')
break outer;
} else if (city === array[3][j]) {
alert('США')
break outer;
} else {
alert('Такого города не найдено')
}
}
}
var gotCity = false
outer: for (let i in array) {
console.log(array[i])
for(let j in array[i]) {
console.log(array[i][j])
if(city === array[0][j]) {
gotCity = city
alert('Казахстан')
break outer;
} else if (city === array[1][j]) {
alert('Россия')
gotCity = city
break outer;
} else if (city === array[2][j]) {
alert('Китай')
gotCity = city
break outer;
} else if (city === array[3][j]) {
alert('США')
gotCity = city
break outer;
}
}
}
if (gotCity === false) {
alert('Такого города не найдено');
}
$(selector).hover(inFunction,outFunction);
foreach ($employees as $key => $value)
перебирается массив $employees. Условие if ($value > 15000)
срабатывает для элементов employee_3, employee_6 и employee_7. Соответственно для остальных элементов срабатывает else (ведь у них ЗП меньше 15000). Код отрабатывает верно. // дочерний компонент your-component
...
methods: {
doSomething() {
this.$emit('yourEvent', {
params: this.params,
})
}
}
// родительский компонент
<template>
<your-component :someProps="parent" @yourEvent="doSomething" />
</template>
...
methods: {
doSomething(data) {
// какой-то код
}
}