PHP missing array grandchild| User | Message | |
Posted : Friday, 23 September 2011, 04:37 | Permalink | Mark Here |
HoboBen

 
WW Entries : 9
|
I have some code for building a HTML table from PHP.
-->
Usage:
-->
And the result:
-->
If you note, var_dump($tr) correctly dumps the <tr>, including child <td> elements.
However, var_dump($table), while correctly var_dumping the <tr> elements, does not var_dump the grandchild <td> elements -- note the empty array ["td"]=> array(0) { }
Do you know why this might be happening?
Thanks
-----
github |
 | |
| Posted : Saturday, 24 September 2011, 04:29 | Permalink | Mark Here |
HoboBen

 
WW Entries : 9
| | Posted : Sunday, 25 September 2011, 03:19 | Permalink | Mark Here |
JL235

 
WW Entries : 7
|
What version of PHP are you using?
It's my understanding that PHP uses references instead of copying in recent versions (at least in 5.3).
----- PlayMyCode.com - build and play in your browser, Blog, Twitter. |
 | |
| Posted : Sunday, 25 September 2011, 12:32 | Permalink | Mark Here |
HoboBen

 
WW Entries : 9
|
5.3.3 on my laptop (where I ran the code) slightly older on the server.
-->
It was a great answer though: the ampersand in the function definition was something I didn't know how to do in PHP. It solved the immediate problem and also taught me how to apply this to other situations.
-----
github |
 | |
|
|