Jump to content

array value handling


brainstem

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 ~
<?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 ~
<?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)\">");
exit();
...
?>

call_state.php ~
<?php
echo <<<html
... // in a table blah blah blah
$state //echos errorlevel
$linkstate //echos appropriate link in case browser doesn't support refresh.
...
html;
?>
Link to comment
https://forums.phpfreaks.com/topic/22116-array-value-handling/
Share on other sites

Archived

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

×
×
  • Create New...

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.