Jump to content

Print Array info


mcfmullen

Recommended Posts

You can ignore my previous thread: Xpath help. I made it needlessly complicated!

 

Here's my problem:

 

My array $selected contains:

Array 
( 
[0] => SimpleXMLElement Object 
( 
	[@attributes] => Array 
	( 
		[buildingName] => EiffelTower 
		[code] => lM 
		[type] => building 
	) 
	[requiredLevel] => 5 
	[cost] => 5000 
	[built] => 03/31/1889 
	[storageType => SimpleXMLElement Object 
	( 
		[@attributes] => Array 
		( 
			[itemClass] => EiffelTower_construct 
		) 
	) 
	[defaultItem] => SimpleXMLElement Object 
	( 
		[@attributes] => Array 
		( 
			[amount] => 1 
			[name] => iron 
		) 
	) 
	[finishedReward] => iron 
	[image] => Array 
	( 
		[0] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[loadClass] => mc 
				[name] => construct_0 
				[url] => /buildings/eiffel_tower.swf 
			) 
		) 
		[1] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[loadClass] => mc 
				[name] => construct_1 
				[url] => /buildings/eiffel_tower.swf 
			) 
		) 
		[2] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[loadClass] => mc 
				[name] => built_0 
				[url] => /buildings/eiffel_tower.swf 
			) 
		) 
		[3] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[name] => icon 
				[url] => buildings/eiffel_tower.png 
			) 
		) 
		[4] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[name] => startIcon 
				[url] => /buildings/eiffel_tower.png 
			) 
		) 
		[5] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[name] => halfIcon 
				[url] => /buildings/eiffel_tower.png 
			) 
		) 
		[6] => SimpleXMLElement Object 
		( 
			[@attributes] => Array 
			( 
				[name] => completeIcon 
				[url] => /buildings/eiffel_tower.png 
			) 
		) 
	) 
	[constructionUI] => /buildings/Construct_eiffel_tower.swf 
	[countryCard] => france 
)
)

 

I have the following code:

echo "<td>".$selected[0]['name']."</td>";
echo "<td>".$selected[0]['code']."</td>";
echo "<td>".$selected[0]['type']."</td>";
echo "<td>".$selected['requiredLevel']."</td>";

 

This line of that code does not work:

echo "<td>".$selected['requiredLevel']."</td>";

 

I've tried:

echo "<td>".$selected[0]['requiredLevel']."</td>";

which also does not work.

 

Can anyone help me figure out why?[/code]

Link to comment
Share on other sites

Don't complain to loudly about not being helped with-in a spawn of only 5 hours.

 

But any way, I think the reason  nobody replied was the fact that your question wasn't clear enough. It sounded as though you were wanting help printing out the entire contents of the array, but from your last post you instead needed the contents of 1 element in the array.

Link to comment
Share on other sites

Seemed pretty clear to me that I was having problems with one particular line of code.

 

In any case, it was a problem that persisted for 2 weeks (started in another topic) to which I've never had a response.

 

I'm sorry for my comment, I didn't mean to come off as ungrateful. The people here are, in fact, extremely helpful and deserve a lot more credit than are given.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.