This is a discussion on in_array within the PHP Language forums, part of the PHP Programming Forums category; hi- i am adding and and or operators to a search engine i will have hooked up to my personal ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
hi-
i am adding and and or operators to a search engine i will have hooked up to my personal bookmarks on my website. i wanted to get rid of duplicate page_url when i chain the conditions together like tcl or delphi or sqlite returns: http://j_m_mc.tripod.com 12 http://www.dubaron.com 11 http://www.dubaron.com 4 http://j_m_mc.tripod.com 3 probably the correct thing to do is add the occurrence number together and omit a url. so one url is listed with the sum of the occurrence. right now i'd be happy with getting rid of the duplicate and having the occurrence be a little off. i'll think about tackling accurate occurrence later. i think the problem in my code is when i call in_array() it is not finding the url (EVER). what i wanted to do is create an array and push a url onto this new array every time that url is not found. if it is found then my code takes a different action. this way (i thought) duplicate urls dont get displayed. here is my code...thanks for any help. jim $unique = array ('init'); reset($or_sql); reset($and_sql); $ar_merge=array_merge($or_sql,$and_sql); while($array_cell = each($ar_merge)) { $current_value = $array_cell[0]; $current_key = $array_cell[1]; if ($array_cell[1] !=' ') { while ($row = mysql_fetch_array($array_cell[1])) { if (in_array($row[0],$unique)) { } else { print( "$row[0] $row[1] </br> "); // store in array Array_push($unique,$row[0]); } } } |
|
|||
|
> i think the problem in my code is when i call in_array() it is not
> finding the url (EVER). what i wanted to do is create an array and push if in_array is not matching, you may have hidden characters - try adding a \n to the end of what you're looking for. this has worked for me after some head scratching |
|
|||
|
"deko" <www-dot-clearpointsystems-dot-com@nospam.com> wrote in
news:cPu8d.5204$JG2.2221@newssvr14.news.prodigy.co m: > if in_array is not matching, you may have hidden characters - try > adding a \n to the end of what you're looking for. this has worked > for me after some head scratching > > thanks for the tip about hidden characters. after too many attempts i decided to hell with it. i can come back later and mess with explode, implode, and search functions for strings. maybe going that route i will have better luck. for now it is working and is correct (just not consolidated enough). it will be ok. i'd like to put the site on the web soon. i can make improvements like this later. thanks again, jim |
|
|||
|
"j-marvin" <customer@service.boy> wrote in message news:Xns9579366A4326Fleavemealone@24.24.2.165... > hi- > > i am adding and and or operators to a search engine i will have hooked > up to my personal bookmarks on my website. i wanted to get rid of > duplicate > page_url when i chain the conditions together like > http://www.php.net/array_count_values/ |
|
|||
|
"Chung Leong" <chernyshevsky@hotmail.com> wrote in news:zZydnYECa7mBq_
7cRVn-ow@comcast.com: > http://www.php.net/array_count_values/ > > thanks Chung . i took a look at the link and it looks very promising. i have to head to work now but will look into this code when i am finished with my shift. have a good week :-) jim |