470,863 Members | 1,152 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,863 developers. It's quick & easy.

array question

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
2 3023
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
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.

Similar topics

3 posts views Thread by SilverWolf | last post: by
9 posts views Thread by buda | last post: by
3 posts views Thread by Pol Bawin | last post: by
11 posts views Thread by Geoff Cox | last post: by
104 posts views Thread by Leszek | last post: by
51 posts views Thread by Pedro Graca | last post: by
7 posts views Thread by heddy | last post: by
8 posts views Thread by T. Wintershoven | last post: by
4 posts views Thread by mab464 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.