How to get unique id from array
1 Attachment(s)
Hello everyone, i have no idea to get unique id from Array (maybe loop for etc?
|
Re: How to get unique id from array
Non tested.
PHP Code:
|
Re: How to get unique id from array
If you always have the ids in sorted order like in your example, then the solution can be done more efficiently(one pass over 2 or O(n) vs O(n^2)) compared to ARUKARI's solution.
PHP Code:
Note that I assumed your ids are >0. The code will not work correctly if some ids are -1. You also need to handle the case when the array is empty(just check before doing anything). If the ids are not sorted, then you can still do it in only one pass(O(n)), by using a trie(assuming the trie implementation inside AMXX provides O(1) access on average). If it is a tree-based implementation, then likely it provides O(log(n)) access which results in an O(n * log(n)) overall complexity, which is still better than O(n^2). Keep in mind that this matters only when the size of your array grows. If your array is small, then any solution will do just fine. Below is the solution using a trie: PHP Code:
PHP Code:
|
Re: How to get unique id from array
Its still not working in my mind.
When record == 1 its working. But records > 1 motd will be broken There my code: |
Re: How to get unique id from array
I don't know how jackpotSkin is structured.
I think the size is different. PHP Code:
|
Re: How to get unique id from array
Thanks bro
Your function not working because always showing same member |
Re: How to get unique id from array
Your statements are too complicated for me
Quote:
|
Re: How to get unique id from array
Okay, use this:
PHP Code:
PHP Code:
|
Re: How to get unique id from array
is this stock to be called inside a function with motd?
Quote:
|
Re: How to get unique id from array
You need to call this to do what you asked in your original post: get unique ids from an array.
|
| All times are GMT -4. The time now is 21:19. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.