Jump to content

[WARNING! Only a Super Genius can solve this] Array with unique values?


onedumbcoder

Recommended Posts

:facepalm:

 

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.

Link to comment
Share on other sites

:facepalm:

 

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

Link to comment
Share on other sites

:facepalm:

 

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.

Link to comment
Share on other sites

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!

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.