Two dimensional array problem

Posted on 2009-05-07
Last Modified: 2012-05-06

I'm trying to create a simple two dimensional array in PHP, following a guide pulled from the net.  My code is below.  I'm getting the usual undefined use of constant error, please help.
$pages = array( 

			   	array( Post => "homepage", Value => "homepage_page" ),

				array( Post => "contact", Value => "contact_page" ),

				array( Post => "status", Value => "status_page" ),


Open in new window

Question by:nickmarshall
1 Comment

Accepted Solution

bljak earned 500 total points
ID: 24324156
Where warning of course is true, neither Post nor Value are constants and can not be used without being quoted, take a look below for 2 possible solutions.

$pages = array(

	array( "Post" => "homepage", "Value" => "homepage_page" ),

	array( "Post" => "contact", "Value" => "contact_page" ),

	array( "Post" => "status", "Value" => "status_page" ),



define("Post", "Post");

define("Value", "Value");

$pages = array(

	array( Post => "homepage",Value => "homepage_page" ),

	array( Post => "contact", Value => "contact_page" ),

	array( Post => "status",  Value => "status_page" ),



Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CA single sign on 2 73
Use PHPSESSID or create new session when user visits page for the first time 4 36
php string masking 4 27
javascript date picker in php while loop 5 22
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now