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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
htacces issue 2 37
Install MySQL 5.6 and PHP on Centos Linux 6 48
.htaccess file settings 4 31
PHP string issue 5 16
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now