![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2009
Location: Plymouth, UK
Posts: 7
OS: windows vista business SP1
|
[SOLVED] PHP: how to replace values of an array with values from 2nd array
hi
I'm a bit unexperienced in this, so I need some help I have two arrays: $users Array ( [1] => esso82 [4] => semkovic [8] => krtko2121 ) and $msg Array ( [0] => 1 [1] => 4 [2] => 8 [3] => 1 ) what do I need to do, is go through the second array and replace its values by values from first array where value of second array is a key of first array do you understand me? say we don't need to replace those values, we can make another array, but it should end up like this: ie $output Array ( [0] => esso82 [1] => semkovic [2] => krtko2121 [3] => esso82 ) thanks for any help, as my logic is nort working at the moment :D |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Nov 2009
Posts: 2
OS: Windows 7
|
Re: PHP: how to replace values of an array with values from 2nd array
Hello, if you still need help, try this
![]() PHP Code:
That thing above will create a new array $output, with keys from $msg and values from $users using "user_id" from $msg. It has one check. If in $msg will be some "user_id" that is not in $users, it will try to add a value that doesn't exists and thus creating a Notice, and that's bad. So it will rather skip that bad iteration. ![]() I hope that helped, and sorry for my bad English, maybe I could use google translate with better effect next time
|
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Oct 2009
Location: Plymouth, UK
Posts: 7
OS: windows vista business SP1
|
Re: PHP: how to replace values of an array with values from 2nd array
hi buddy, thanks for your post, but I fergot to update, I already sorted this out the same way ... my logics started to work again :D ... but thanks once again :D
|
|
|
|
|
|
#4 (permalink) |
|
God (TSF Enthusiast)
Join Date: May 2009
Location: Jeffersonville, IN
Posts: 888
OS: Ubuntu 9.10 [Karmic Koala]
|
Re: PHP: how to replace values of an array with values from 2nd array
Please mark this post as solved.
Go up to the original post and under "Thread Tools" you'll find "Mark as Solved" or something similar. |
|
|
|
![]() |
| Thread Tools | |
|
|