Answer the question
In order to leave comments, you need to log in
PHP: How to add key => array() element to array?
The task should be very simple, but programming for 5 years in PHP I can not solve it.
There is this pseudocode:
<?php
$brend = array();
//.../
$city = 6;
$brend = 11;
//.../
if (!isset($brend[$city])){
$brend[$city] = array();
}
if (!isset($brend[$city][$brend])){
$brend[$city][$brend] = array('eff'=>0,'count'=>0);
}
//.../
$count = $brend[$city][$brend]['count'];
Answer the question
In order to leave comments, you need to log in
Well, of course he will swear.
$city = 6; is int.
$brand = 11; is also a variable of type int.
To it, you supposedly make an array 11['6'] - of course, this is not true, it is not an array.
You need to do this $arr[$brend][$city], then the variable $arr[11][6] will be an array.
Video tutorial on arrays , may be useful.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question