[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: SV: SV: SV: [PROGRAMMERING] Rekursion i php



On Sun, 21 Dec 2003, Jan Andersen wrote:

> echo "HEJ".$array[7][8]['titel']."HEJ";

hmm, prøv Ole's eksempel
	echo "HEJ".$array[0][0]['titel']."HEJ";
så skulle der være bid

> [3]=>
>     array(7) {
>       ["id"]=>
>       string(1) "8"
>       ["site"]=>
>       string(6) "Sitet"
>       ["link"]=>
>       string(30) "Linket"
>       ["titel"]=>
>       string(19) "Titel5"
>       ["tekst"]=>
>       string(694) "Teksten"
>       ["far"]=>
>       string(1) "5"
> 
> Ja men det bliver man ikke klogere af .. eller rette jeg gør ikke..

Nu kan jeg jo ikke se hele dumpet, men jeg kan se:
* du har en far der hedder "3"
* far3 har 7 sønner
* første søn hedder "8"

Denne skal så skrive:
        echo "HEJ ".$array[3][0]['titel']." JEH";
	HEJ Titel5 JEH

Nå, men hvis den site du viser nu er id=8, og så skal gå et niveau op, 
så har du ret i at det ikke er helt nemt. Nemmest ville det være med 
en ekstra tabel med to kolonner hvor key er søn og value er far.
Key er også det du kalder id.

søn|far
---+---
 8 | 2
 2 | 0

Den tabel bygges også op i samme loop som omtalt før.

$sonfar[8] = 2;
$sonfar[2] = 0;

/hans
-- 
Hamletsgade 4 - 201, DK-2200 København N, Phone: +45 3582 9079
Schou Industries ApS      http://schou.dk/    CVR: 26 13 44 39
--------------------------------------------------------------
I spent probably 20 or 30 hours drawing the penguin stuff, and
I've spent four or five years writing code, and I'm still
known for the penguin a lot more than I am for any of the code.
			-- Larry Ewing, creator of Tux


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *