$array = json_decode($js);
for ($i = 0; $i < count($array); $i++){
print "<div>{$array[$i]->Ev}</div>";
}
$additionalFields = [
'slider' => '{"slider0":{"File":"images\/about2.png"},"slider1":{"File":"images\/img3.png"},"slider2":{"File":"images\/news.png"}}'
];
echo '';
print_r($additionalFields);
echo '';
$result = json_decode($additionalFields['slider'], true);
$queries = [
[
'technologies' => [
'75',
'76',
'77',
]
],
[
'query' => 'php',
'technologies' => [
'78',
'79',
'75',
]
],
];
$result = [];
foreach ($queries as $query) {
foreach ($query['technologies'] as $technology) {
if (isset($result[$technology])) {
$result[$technology] += 1;
} else {
$result[$technology] = 1;
}
}
}
var_dump($result);
$products = [
[
'product_id' => 200,
'options' => [
[
'quantity' => 1,
'option_id' => 199,
'option_value_id' => 500,
]
],
],
[
'product_id' => 201,
'options' => [
[
'quantity' => 1,
'option_id' => 200,
'option_value_id' => 501,
]
],
],
];
$newProduct = [
'product_id' => 201,
'options' => [
[
'quantity' => 5,
'option_id' => 200,
'option_value_id' => 501,
]
],
];
$products = array_map(function (array $product) use ($newProduct) {
if ($product['product_id'] === $newProduct['product_id']) {
$product['options'][0]['quantity'] += $newProduct['options'][0]['quantity'];
}
return $product;
}, $products);
var_dump($products);
$xls->getActiveSheet()->toArray()
получив всю информацию с листа в массив.public function comments()
{
return $this->hasMany(Comment::class, 'article_id');
}
[
{
"id": 1,
"title": "title_1_article",
"comments": [
{
"id": 1,
"article_id": 1,
"comment": "first_comment"
},
{
"id": 2,
"article_id": 1,
"comment": "second_comment"
}
]
}
]
$foo = 'myemail@mail.com';
preg_match('/^[\w-\.]+@[\w-]+\.[a-z]{2,4}$/i', $foo, $matches);
echo $matches[0];