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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 2nd, 2002, 05: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: 2
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, 05: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: 24
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, 05: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: 2
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, 06: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: 2
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, 06: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: 2
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, 06: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: 2
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, 06: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: 2
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, 06: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: 2
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, 04: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: 24
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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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