?
Solved

Two dimensional array problem

Posted on 2009-05-07
1
Medium Priority
?
271 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 2000 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 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