Jump to content


This topic is now archived and is closed to further replies.


array value handling

Recommended Posts

Here is my issue (I am still green, be nice);
Trying to pull values from 2 arrays based on error or changed state, i.e you just logged in, you didn't fill a form right, etc...
This is going to be implimented accoss a large site with multiple dir levels so i wanted an include to handle arrays where all of the errorlevel and messagelevel information was and thier corresponding links.

The issue i'm having is, I have accomplished this with 'list' but its very cumbersome and I know there is a way to compact it down to a simple $array[0] type call but i cant get it to work.
here is my code, plz help. The error i am currently getting is 'Unexpected ['.
thanks in advance.

call_defs.php ~
$statei = array(0=>'Error(s) Found.',1=>'Success!',2=>'Logging In '.$user.'.',3=>'Logging Out '.$user.'.',4=>'Welcome Administrator');
$linki = array(0=>'javascript:history.back()',1=>'console.php',2=>'login.php',3=>'../index.php');


index.php ~

if ($err<>null) {
include ("call_defs.php");
$state = &statei[0]; //FAILING ON THIS LINE 'Unexpected ['
$linkstate = &linki[0];
include ("call_state.php");
echo ("<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=javascript:history.back(-1)\">");

call_state.php ~
echo <<<html
... // in a table blah blah blah
$state //echos errorlevel
$linkstate //echos appropriate link in case browser doesn't support refresh.

Share this post

Link to post
Share on other sites
onlamp is now on my php blacklist.
A help reference on getting values out of arrays told me to use & instead of $ when calling directly to an array value.
thanks anyway

Share this post

Link to post
Share on other sites


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.