By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

array question

P: n/a
I'm just starting in php, although I have a little programming experience in
other languages, but only on a surface level. I'm hoping someone can help me.

I have a multidimensional array that I want to pull information from on a
bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"http://www.co.adams.wa.us/default.asp"
demwebsite=>"" ),
array ( name=>"Asotin",

I'm trying to write the php script for the pages to identify the sub array
by the filename, pull the rest of the information out of the array into
variables, and then use those variables to write the page. I've searched
and tried a bunch of things, and nothing is working. Here is what I have:

<?php
include("countiesarray.inc");
$path = __FILE__;
$filename = basename ($path,".php");
foreach ($county as $key => $ArrayRow)
{
if ($ArrayRow[0] == $filename)
{$countyname = $ArrayRow[name];
$govwebsite = $ArrayRow[govwebsite];
$demwebsite = $ArrayRow[demwebsite];
};
);
include ("header.html");
include ("title.html");
if ( $govwebsite != "" ) { include ("countyweb.html"); };
if ( $demwebsite != "" ) { include ("countydemweb.html"); };
include("../navigation.html");
include("../copyright.html");
?>

The error I get is Parse error:
parse error in /home/calador/public_html/wapolitics/counties/adams.php on line 12.
Line 12 is the end of the foreach loop. Can someone tell me what I'm doing wrong?

Chad Lupkes
ch********@earthlink.net
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Chad Lupkes wrote:
I'm just starting in php, although I have a little programming experience in
other languages, but only on a surface level. I'm hoping someone can help me.

I have a multidimensional array that I want to pull information from on a
bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"http://www.co.adams.wa.us/default.asp"
demwebsite=>"" ),
array ( name=>"Asotin",

I'm trying to write the php script for the pages to identify the sub array
by the filename, pull the rest of the information out of the array into
variables, and then use those variables to write the page. I've searched
and tried a bunch of things, and nothing is working. Here is what I have:

<?php
include("countiesarray.inc");
$path = __FILE__;
$filename = basename ($path,".php");
foreach ($county as $key => $ArrayRow)
{
if ($ArrayRow[0] == $filename)
{$countyname = $ArrayRow[name];
$govwebsite = $ArrayRow[govwebsite];
$demwebsite = $ArrayRow[demwebsite];
};
);
include ("header.html");
include ("title.html");
if ( $govwebsite != "" ) { include ("countyweb.html"); };
if ( $demwebsite != "" ) { include ("countydemweb.html"); };
include("../navigation.html");
include("../copyright.html");
?>

The error I get is Parse error:
parse error in /home/calador/public_html/wapolitics/counties/adams.php on line 12.
Line 12 is the end of the foreach loop. Can someone tell me what I'm doing wrong?

Chad Lupkes
ch********@earthlink.net Hello,

There is a little error in your code. This following script should be ok: <?php
include("countiesarray.inc");
$path = __FILE__;
$filename = basename ($path,".php");
foreach ($county as $key => $ArrayRow)
{
if ($ArrayRow[0] == $filename)
{$countyname = $ArrayRow[name];
$govwebsite = $ArrayRow[govwebsite];
$demwebsite = $ArrayRow[demwebsite]; }
} include ("header.html");
include ("title.html");
if ( $govwebsite != "" ) { include ("countyweb.html"); };
if ( $demwebsite != "" ) { include ("countydemweb.html"); };
include("../navigation.html");
include("../copyright.html");
?>


Try this...

Jul 17 '05 #2

P: n/a
Ok, we're getting closer, but I'm still getting errors.

Parse error: parse error, expecting `')'' in
/home/calador/public_html/wapolitics/counties/countiesarray.inc on line 7

Warning: Invalid argument supplied for foreach() in
/home/calador/public_html/wapolitics/counties/adams.php on line 5

--
Chad Lupkes
ch********@yahoo.com
http://www.seattlewebcrafters.com/
"OSIRIS" <dj******@free.fr> wrote in message
news:3f**********************@news.free.fr...
Chad Lupkes wrote:
I'm just starting in php, although I have a little programming experience in other languages, but only on a surface level. I'm hoping someone can help me.
I have a multidimensional array that I want to pull information from on a bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"http://www.co.adams.wa.us/default.asp"
demwebsite=>"" ),
array ( name=>"Asotin",

I'm trying to write the php script for the pages to identify the sub array by the filename, pull the rest of the information out of the array into
variables, and then use those variables to write the page. I've searched and tried a bunch of things, and nothing is working. Here is what I have:
<?php
include("countiesarray.inc");
$path = __FILE__;
$filename = basename ($path,".php");
foreach ($county as $key => $ArrayRow)
{
if ($ArrayRow[0] == $filename)
{$countyname = $ArrayRow[name];
$govwebsite = $ArrayRow[govwebsite];
$demwebsite = $ArrayRow[demwebsite];
};
);
include ("header.html");
include ("title.html");
if ( $govwebsite != "" ) { include ("countyweb.html"); };
if ( $demwebsite != "" ) { include ("countydemweb.html"); };
include("../navigation.html");
include("../copyright.html");
?>

The error I get is Parse error:
parse error in /home/calador/public_html/wapolitics/counties/adams.php on line 12. Line 12 is the end of the foreach loop. Can someone tell me what I'm doing wrong?
Chad Lupkes
ch********@earthlink.net

Hello,

There is a little error in your code. This following script should be ok:
> <?php
> include("countiesarray.inc");
> $path = __FILE__;
> $filename = basename ($path,".php");
> foreach ($county as $key => $ArrayRow)
> {
> if ($ArrayRow[0] == $filename)
> {$countyname = $ArrayRow[name];
> $govwebsite = $ArrayRow[govwebsite];
> $demwebsite = $ArrayRow[demwebsite];

}
}
> include ("header.html");
> include ("title.html");
> if ( $govwebsite != "" ) { include ("countyweb.html"); };
> if ( $demwebsite != "" ) { include ("countydemweb.html"); };
> include("../navigation.html");
> include("../copyright.html");
> ?>


Try this...

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 11/22/2003
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.