onedumbcoder Posted September 4, 2009 Author Share Posted September 4, 2009 wow... never mind i just realized i was the one that said that Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-912728 Share on other sites More sharing options...
Daniel0 Posted September 4, 2009 Share Posted September 4, 2009 I don't want to sound demeaning, but looking at your topics, maybe you should reconsider your hobby/career choice? Or maybe you should just stop for a while and take a look at what you're doing. You are failing at really elementary logic all the time. Before someone says I can't say that, I'm saying this as Daniel, not as PHP Freaks admin. Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-912734 Share on other sites More sharing options...
l0ve2hat3 Posted September 5, 2009 Share Posted September 5, 2009 I don't want to sound demeaning, but looking at your topics, maybe you should reconsider your hobby/career choice? Or maybe you should just stop for a while and take a look at what you're doing. You are failing at really elementary logic all the time. Before someone says I can't say that, I'm saying this as Daniel, not as PHP Freaks admin. ouch Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-912879 Share on other sites More sharing options...
onedumbcoder Posted September 5, 2009 Author Share Posted September 5, 2009 I don't want to sound demeaning, but looking at your topics, maybe you should reconsider your hobby/career choice? Or maybe you should just stop for a while and take a look at what you're doing. You are failing at really elementary logic all the time. Before someone says I can't say that, I'm saying this as Daniel, not as PHP Freaks admin. Are u talking about preg_match? I know its failing, that is why i have been trying to solve. Please reads the question before. Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-912975 Share on other sites More sharing options...
PugJr Posted September 5, 2009 Share Posted September 5, 2009 Onedumbcoder, what is wrong with what these people have already shown you? They have given you the code so whats hard to just use it or is this something you want to learn how to do yourself? Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-912978 Share on other sites More sharing options...
l0ve2hat3 Posted September 8, 2009 Share Posted September 8, 2009 using exactly what garethp suggested but in a function... function is_unique($array){ return (count(array_unique($array)) == count($array))?true:false; } //FIRST ARRAY - NOT UNIQUE $arr1[]=123; $arr1[]=123; //SECOND ARRAY - UNIQUE $arr2[]=1; $arr2[]=2; //CHECK IF arr1 IS UNIQUE if(is_unique($arr1)){ echo "arr1 IS UNIQUE!<BR>\n"; }else{ echo "arr1 IS NOT UNIQUE!<BR>\n"; } //CHECK IF arr2 IS UNIQUE if(is_unique($arr2)){ echo "arr2 IS UNIQUE!<BR>\n"; }else{ echo "arr2 IS NOT UNIQUE!<BR>\n"; } This should output: arr1 IS NOT UNIQUE! arr2 IS UNIQUE! Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-914501 Share on other sites More sharing options...
Garethp Posted September 8, 2009 Share Posted September 8, 2009 using exactly what garethp suggested but in a function... function is_unique($array){ return (count(array_unique($array)) == count($array))?true:false; } //FIRST ARRAY - NOT UNIQUE $arr1[]=123; $arr1[]=123; //SECOND ARRAY - UNIQUE $arr2[]=1; $arr2[]=2; //CHECK IF arr1 IS UNIQUE if(is_unique($arr1)){ echo "arr1 IS UNIQUE!<BR>\n"; }else{ echo "arr1 IS NOT UNIQUE!<BR>\n"; } //CHECK IF arr2 IS UNIQUE if(is_unique($arr2)){ echo "arr2 IS UNIQUE!<BR>\n"; }else{ echo "arr2 IS NOT UNIQUE!<BR>\n"; } This should output: arr1 IS NOT UNIQUE! arr2 IS UNIQUE! Thanks, but this wasn't my code. In fact, if it were me, I would have looped through the whole array to check for the value. But now I know about this function, so I'd use this in the future. I actually have to give the credit to Daniel0 on Page 1 Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-914502 Share on other sites More sharing options...
RussellReal Posted September 8, 2009 Share Posted September 8, 2009 honestly guys.. I think hes acting retarded on purpose.. so just don't reply to this post.. delete the topic.. and ban this kid.. Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-914507 Share on other sites More sharing options...
newbtophp Posted September 8, 2009 Share Posted September 8, 2009 honestly guys.. I think hes acting retarded on purpose.. so just don't reply to this post.. delete the topic.. and ban this kid.. i agree, im new to php but i dont go around acting dumb on purpose. hes got quite alot of replies and yet he has not solved it, usually 1-3 replies do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/173145-warning-only-a-super-genius-can-solve-this-array-with-unique-values/page/2/#findComment-914517 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.