473,245 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

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 3311
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: SilverWolf | last post by:
I need some help with sorting and shuffling array of strings. I can't seem to get qsort working, and I don't even know how to start to shuffle the array. Here is what I have for now: #include...
9
by: buda | last post by:
Hi, I've been wondering for a while now (and always forgot to ask :) what is the exact quote from the Standard that forbids the use of (&array) (when x >= number_of_columns) as stated in the FAQ...
3
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array...
11
by: Geoff Cox | last post by:
Hello, I am trying to get a grip on where to place the initialization of two arrays in the code below which was created using Visual C++ 2005 Express Beta 2... private: static array<String^>^...
28
by: anonymous | last post by:
I have couple of questions related to array addresses. As they belong to the same block, I am putting them here in one single post. I hope nobody minds: char array; int address; Questions...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
51
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc...
7
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are...
8
by: T. Wintershoven | last post by:
Hello all, I have a form with some checkboxes. The names of these checkboxes come from an array. When i click the submit button the resultcode doesn't recognize the names when i want to check...
4
by: mab464 | last post by:
I have this code on my WAMP server running on my XP machine if ( isset( $_POST ) ) { for($i=0; $i<count($_POST);$i++) { if ($ans != NULL ) $ans .= ", " . $_POST ; // Not the first...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.