473,908 Members | 5,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 multidimensiona l array that I want to pull information from on a
bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"ht tp://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("counti esarray.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.htm l"); };
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********@eart hlink.net
Jul 17 '05 #1
2 3390
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 multidimensiona l array that I want to pull information from on a
bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"ht tp://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("counti esarray.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.htm l"); };
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********@eart hlink.net Hello,

There is a little error in your code. This following script should be ok: <?php
include("counti esarray.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.htm l"); };
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.i nc on line 7

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

--
Chad Lupkes
ch********@yaho o.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 multidimensiona l array that I want to pull information from on a bunch of pages.

$county = array (
array (
key=>"adams",
name=>"Adams",
govwebsite=>"ht tp://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("counti esarray.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.htm l"); };
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********@eart hlink.net

Hello,

There is a little error in your code. This following script should be ok:
> <?php
> include("counti esarray.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.htm l"); };
> 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
6419
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 <stdio.h> void main(void) { char lines; int count = 0, i;
9
2631
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 6.19 (http://www.eskimo.com/~scs/C-faq/q6.19.html). Thanks.
3
2702
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 is initialized with one element it works fine) But I can not change the initial state of the array. It must be null. what must I change.
11
2277
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^>^ LHSquestions = gcnew array<String^> {"question 1","question 2"}; private: static array<String^>^ RHSquestions = gcnew array<String^> {"question 1",
28
2472
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 1: Why cannot I do the following:
104
17060
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 that array Could you show me a little example how to do this? Thanks.
51
23791
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 10018-clc.c: In function `main': 10018-clc.c:22: warning: array subscript has type `char' I don't like warnings ... or casts.
7
6447
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 now thown out of the array released properly by the CLI?
8
1491
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 wether or not some checkboxes are ticked. Assume that i tick checkboxes 100, 150 and 200 Below is some code i've used.(between the ****** lines)
4
4571
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 element so append a comma
0
10035
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9876
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10915
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10537
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8096
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5933
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6137
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4772
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3357
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.