Solved

Two dimensional array problem

Posted on 2009-05-07
1
267 Views
Last Modified: 2012-05-06
Experts,

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

0
Comment
Question by:nickmarshall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
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.
//first
$pages = array(
	array( "Post" => "homepage", "Value" => "homepage_page" ),
	array( "Post" => "contact", "Value" => "contact_page" ),
	array( "Post" => "status", "Value" => "status_page" ),
);
 
 
 
//second
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" ),
);
var_dump($pages); 

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

734 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