FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How best to print an array to table?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How best to print an array to table? [message #178265 is a reply to message #178254] Fri, 25 May 2012 16:24 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Thu, 24 May 2012 22:19:21 -0400, richard wrote:

> On Fri, 25 May 2012 00:51:24 +0200, Michael Fesser wrote:

>> print "<td>{$Alist['aname']}</td>";

> Does not work in this case.
> www.1littleworld.net/sample/test2.php

Perhaps you could show us the php you used, rather than link us to a
website that only shows us the results of that php.

The code suggested will work if you type it correctly. If you don't type
it correctly, eg miss out or change bits, it won't work.

Note for example, that:

The normal use may be $array["key"] or $array['key']

To be used inside a string delimited with "" needs the use of of '' for
the array key:

$array['key']

the whole $array['key'] has to be enclosed in the curly brackets:

{$array['key']}

Then it can be included in a string that is enclosed in double quotes:

print "{$array['key']}";

which can also include other text:

print "<td>{$array['key']}</td>";

Which bit did you fuck up? No $ symbol? Didn't use the curly brackets?
Put the curly brackets in the wrong places? Used the same quotes for the
array key as the string? Got the array name or key name wrong?

Here's an example of it working:

http://www.sined.co.uk/tmp/array_print.php

Using this php (irrelevant bits snipped):

$array = array( "cold"=>"penguin" );

$content .= "<p>The value of \"{\$array['cold']}\" is: \"{$array['cold']}
\"</p>";

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem setting Date field in MySQL
Next Topic: What is this attack trying to do?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 03:55:08 GMT 2024

Total time taken to generate the page: 0.04219 seconds