vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need help with an Array (https://vborg.vbsupport.ru/showthread.php?t=98637)

PcFreak 10-17-2005 07:46 PM

Need help with an Array
 
I have the following Array

with print_r($output);

Code:

Array ( [Peter] => 32 [Bibo] => 4 [Lili] => 2 [Uwe] => 2 [Didi] => 1 [Freak] => 0)
with print_r(array_keys ($output));

Code:

Array ( [0] => Peter [1] => Bibo [2] => Lili [3] =>  Uwe [4] => Didi [5] => Freak)
with print_r(array_values ($output));

Code:

Array ( [0] => 32 [1] => 4 [2] => 2 [3] => 2 [4] => 1 [5] => 0)
I would like to have a loop for key and value variables, because i want to output this vars in a table on a html page.
e.g

$key[] = ? // Peter, Bibo, Lili etc.
$value[] = ? // 32, 4 ,2 etc

For a table like this

Code:

Key  / value
__________
Peter / 32
Bibo  / 4
Lili  / 2

PcFreak

Andreas 10-17-2005 08:05 PM

PHP Code:

echo('<table>');
echo(
'<tr><td>Key</td><td>Value</td></tr>');
foreach (
$output AS $name => $number)
{
echo(
"<tr><td>$name</td><td>$number</td></tr>");
}
echo(
'</table>'); 


PcFreak 10-17-2005 08:34 PM

Jep.

Thats work.

The print_r command confused me.

Thank you very much

PcFreak


All times are GMT. The time now is 07:02 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01034 seconds
  • Memory Usage 1,715KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete