Answer the question
In order to leave comments, you need to log in
Why doesn't it return the value of the associative array?
php code ===========
$e1 = array(
"t1" => 112,
"t2" => 113);
$e2 = array(
"s1" => 227,
"s2" => 228);
$e = array(
"one" => $e1,
"two" => $e2);
echo ""
===================
* Outputs:
--e1
---t1: 112
---t2: 113
--e2
---s1: 227
- --s2: 228
Next, I'd like to output one array.
===========code php (adding)
$arrMy = $e["one"];
echo ""
===================
The console displays:
<
< illegal string offset 'one' in C:\test\test.php on line 17 >
Answer the question
In order to leave comments, you need to log in
The same code worked perfectly...
If this is just an abstract example, perhaps in real code you have a redefinition of this array, for example $e is used as an iterator in a loop.
foreach ($arrMy as $e => $item) {}
Didn't understand your code. Everything works:
$e1 = array(
"t1" => 112,
"t2" => 113);
$e2 = array(
"s1" => 227,
"s2" => 228);
$e = array(
"one" => $e1,
"two" => $e2);
$arrMy = $e["one"];
print_r($arrMy);
Array
(
[t1] => 112
[t2] => 113
)
unexpected token
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question