Array_unique
I have been working with the following section of code and each time I run my script I get an error that states my function arguument (for array_unique) is not a valid array. Could someone please assist me? I am not sure where the error could be, but I think I have a valid one dimensional array that should go through array_unique....
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Array_unique
I have a directory of files with filenames such as 20070704_A_01.pdf, 20070704_B_03.pdf, etc. I am trying to get the letter, such as A and B, exploded out of the filename. There will be several instances of the same letter, such as 5 letter A's and 6 letter B's, etc. I want to get a unique list of all of the letters. But when I use array_unique, it does not recognize that there are multiple instances of the same letter. The array still looks like: Code:
I Want To Do Array_unique BUT IN REVERSE!
hello everyone. This is a simple problem I think, but I can't work it out. Usually you need to get unique values from an array, but I actually sort of want to do the opposite to that. I need to get all the values from an array that appear more than once, and discard the rest, so like: (orange, banana, strawberry, strawberry, orange, pineapple, orange, orange) becomes (orange, strawberry) Any ideas how I would do that?
Array_unique Is Creating A NULL Array?
I'm writting a find and replace script for my sites internal search. Basically it is for the creation of a list of keywords that can later be fed through the search (kinda an advanced search of sorts)... Anyways, I've rewritten the function several times, and I think I am getting close, but there is one last snag. I am using array_unique() to remove the duplicates that are created by the function, and it is reutrning NULL. What's the deal? function findreplace() { extract($GLOBALS); if ($hold == 1) { return trim(stripslashes($keywords)); } $find = strtolower($_POST['find']); $replace = strtolower($_POST['replace']); $keywords = trim(strtolower($keywords)); //if ($_POST['replace_words'] == "Replace Words") { ....
Implode, Keyword Distinct, And Array_unique?
I have an array of values for subcatid (1,2,3,4,5) called $subcatidarray I have a table called sf_subcategory where each row has the following columns, subcatid, catid, and name. I want to use each value in $subcatidarray to select the catid for that record and then I want to eliminate duplicate values (because subcatid's may share the same catids) then use the array of resulting (non-duplicate) catids to select name from a second table called sf_categories. I think I want to use either Distinct or the function array_unique but I'm stumped how to do this. this is what I've done so far, trying the DISTINCT keyword <?php $str = implode(",",$subcatidarray); $sql="SELECT DISTINCT catid"; $sql .="FROM $pntable[sf_subcategory] WHERE subcatid IN ($str)"; $result = mysql_query($sql); $str2 = implode (",",$result); $sql="SELECT name"; $sql .="FROM $pntable[sf_categories] WHERE catid IN ($str2)"; $result2=mysql_query($sql); ?>
|