PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 2nd, 2002, 06:16 PM
dv8 dv8 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mobile.Alabama
Posts: 32 dv8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to dv8 Send a message via AIM to dv8
Array() Question

How can I echo Array names?
And if I have "nesting doll" array (Meaning an array within an Array) how do echo those inner Arrays names?
I'm full of questions

Reply With Quote
  #2  
Old May 2nd, 2002, 06:33 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Array() Question

Do you mean the key values? If so, if you had this:

$myarray = array("First"=>1,"Second"=>2,"Third"=>3);

you could do this:

foreach($myarray as $key=>$value) {
echo "Key name is: $key<BR>n";
echo "Value is: $value<BR>n";
}




Reply With Quote
  #3  
Old May 2nd, 2002, 06:58 PM
everytime everytime is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: *.*
Posts: 133 everytime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Array() Question

try this code. The function here loop through all the elements in an array recursively. so if there is an array in an array in an array etc (you get the idea) this code will echo the names. I wrote it just but I'm sure you can amended if you need to. I have included an example.
Code:
<?php
function echoArray($arrayName)
{
	foreach ($arrayName as $arrayElement) 
	{
   		if (count($arrayElement) > 1)
		{
			echoArray($arrayElement);
		}
		else
		{
		echo "element value: $arrayElement <br>n";
		};
	};
};

$intensity = array('luminous','neon');
$shades = array('light','dark',$intensity);
$colors = array('red','blue','green', $shades);
echoArray($colors);
?>


hope that helps

Reply With Quote
  #4  
Old May 2nd, 2002, 07:13 PM
dv8 dv8 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mobile.Alabama
Posts: 32 dv8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to dv8 Send a message via AIM to dv8
RE: Array() Question

These Array within Array, can they be stored to a Database?
php Code:
Original - php Code
  1.  
  2. (
  3.     [0] => Array
  4.         (
  5.             [0] => INITIAL
  6.             [1] => 24/2100Z
  7.             [2] => 30.5N
  8.             [3] => 49.5W
  9.             [4] => 50 KTS
  10.         )
  11.  
  12.     [1] => Array
  13.         (
  14.             [0] => 12HR VT
  15.             [1] => 25/0600Z
  16.             [2] => 31.0N
  17.             [3] => 49.5W
  18.             [4] => 50 KTS
  19.         )
  20.  
  21.     [2] => Array
  22.         (
  23.             [0] => 24HR VT
  24.             [1] => 25/1800Z
  25.             [2] => 32.0N
  26.             [3] => 50.0W
  27.             [4] => 50 KTS
  28.         )
  29.  
  30.     [3] => Array
  31.         (
  32.             [0] => 36HR VT
  33.             [1] => 26/0600Z
  34.             [2] => 33.0N
  35.             [3] => 50.9W
  36.             [4] => 50 KTS
  37.         )
  38.  
  39.     [4] => Array
  40.         (
  41.             [0] => 48HR VT
  42.             [1] => 26/1800Z
  43.             [2] => 33.8N
  44.             [3] => 52.0W
  45.             [4] => 50 KTS
  46.         )
  47.  
  48.     [5] => Array
  49.         (
  50.             [0] => 72HR VT
  51.             [1] => 27/1800Z
  52.             [2] => 34.5N
  53.             [3] => 54.0W
  54.             [4] => 50 KTS
  55.         )
  56.  
  57. )

[0] = >Array as new Row
[0] = >Initial as a new Field
...and so on?

Reply With Quote
  #5  
Old May 2nd, 2002, 07:18 PM
everytime everytime is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: *.*
Posts: 133 everytime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Array() Question

don't think you'll be storing arrays in a database. Better for the table to have the necessary fields for the array elements and populate each one when you add the data to the database

Reply With Quote
  #6  
Old May 2nd, 2002, 07:24 PM
dv8 dv8 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mobile.Alabama
Posts: 32 dv8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to dv8 Send a message via AIM to dv8
RE: Array() Question

Well the problem with that is if the data is kept for Historical value.
This data for example is storm data. Well, if the storm is named that would be that table.
Limited amount of databases is the reason for flatting the data as so.

Reply With Quote
  #7  
Old May 2nd, 2002, 07:34 PM
everytime everytime is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: *.*
Posts: 133 everytime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Array() Question

you should use a relational database setp. Have a table of storm names and a unique id for each as the key. In another table hold the stats. Then for each storm id hold rainfall, windspeed etc on the same row and so keep all the data in that one table and storm names in another.

Reply With Quote
  #8  
Old May 2nd, 2002, 07:43 PM
dv8 dv8 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mobile.Alabama
Posts: 32 dv8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to dv8 Send a message via AIM to dv8
RE: Array() Question

Hmm... I think I'm following you...
Can you give an example? So, I see what you mean.

Reply With Quote
  #9  
Old May 3rd, 2002, 05:24 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: Array() Question

Have a table called storms that looks like:

id | name
1 | Andrew
2 | Mark
3 | Michelle
etc

then a table called storm_data that looks like:
stormid | field1 | field2 | field3 | field4 | field5
1 | 48HR VT | 26/1800Z | 33.8N | 52.0W | 50 KTS

etc


Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Array() Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek