Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multidimensional Array - Print Key 1

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA
Hi,

I'm new to PHP and I need some help regarding array manipulation.

I have the following m-dim array and I would like to know how to print the "Key" (50,51,52,53...)

Code:
$Pages = array(
	
	"50" => array (	
				"Title" => "some text 50",
				"Desc" => "some text",
				"Content" => "some text" ),
	"51" => array (	
				"Title" => "some text 51",
				"Desc" => "some text",
				"Content" => "some text" ),
	"52" => array (	
				"Title" => "some text 52",
				"Desc" => "some text",
				"Content" => "some text" ),
	"53" => array (	
				"Title" => "some text 53",
				"Desc" => "some text",
				"Content" => "some text" ),
				
);


Code:
foreach ($Pages as $P) {
	print $P['Title'] . $P . "<br>";
}
 
not fully sure what you mean. might this be after
Code:
foreach ($Pages as $key=>$page):
    echo "Array key $key has title element {$page['Title']} <br/>";
endforeach;
 

Thanks jpadie

That was fast...
It's exactly what I was looking for !


Thank you


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top