Reordering php array - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-22-2010, 10:32 AM   #1 (permalink)
Junior Member
 
Join Date: Nov 2010
Posts: 2
Default Reordering php array

Hi Guys this may be a little hard to understand as I’m not sure I understand it half the time =).

Example Array:

$strings = array(
“key1” => “Hello Key2 Key3”,
“key2” => “World”,
“key3” => “It’s Monday Key2”
);

In the array you may have noticed that the name of keys within the array are dotted around the strings.

This is because I’ll be doing a foreach loop on the array and replacing the keys in the strings with their respective values. So for example after the foreach on the array above the value for key1 would be “Hello World I’ts Monday World”

I want to be able to do the foreach loop that replaces the keys only the once, so this means ill have to reorder the array before looping it. So the new order of the array above will be like so:

$strings = array(
“key2” => “World”,
“key3” => “It’s Monday Key2”
“key1” => “Hello Key2 Key3”,
);

So now above any keys that are referenced in the array strings have their values defined before any reference to the key occurs further down the array. I appreciate that in some circumstances this method of reordering won’t be possible so if key2 references key1 and vice versa the loop will continue until the server goes bang. If this looping is going to occur I need to just dump out a message like “Loop detected”.

I hope this made sense. Any help would be greatly appreciated.
aacuras is offline   Reply With Quote
Sponsored Links
Old 11-22-2010, 11:36 AM   #2 (permalink)
Junior Member
 
BestVibes's Avatar
 
Join Date: Mar 2010
Location: Canada
Posts: 87
Default Re: Reordering php array

Does anyone know why "Hello World" is the defacto lingo used in programming... Why not just use...

"Testing 1 2 3" or

"This is test 1" or

"Hello Wisconsin!"

Okay I guess that is all... thank you for your answers in advance!

Sex Toys Canada



fleshlight canada
_______________

we-vibe canada
BestVibes is offline   Reply With Quote
Old 11-25-2010, 09:52 AM   #3 (permalink)
Junior Member
 
MattCA's Avatar
 
Join Date: Nov 2010
Posts: 13
Default Re: Reordering php array

Quote:
Originally Posted by BestVibes View Post
Does anyone know why "Hello World" is the defacto lingo used in programming... Why not just use...
Following Wiki:
Quote:
While small test programs existed since the development of programmable computers, the tradition of using the phrase "Hello world!" as a test message was influenced by an example program in the seminal book The C Programming Language. The example program from that book prints "hello, world" (without capital letters or exclamation mark), and was inherited from a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial
MattCA is offline   Reply With Quote
Old 12-03-2010, 02:26 AM   #4 (permalink)
Regular User
 
Join Date: Dec 2010
Posts: 249
Default Re: Reordering php array

It is a useful one...........
roja is offline   Reply With Quote
Old 12-09-2010, 02:14 AM   #5 (permalink)
Member
 
Join Date: Feb 2010
Posts: 295
Default Re: Reordering php array

It is full of veins which can make you level up fast. However, there are not many mobs.
kinah is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:04 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting