in_array

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-05-2004
j-marvin
 
Posts: n/a
Default in_array

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]);
}

}
}




Reply With Quote
  #2 (permalink)  
Old 10-05-2004
deko
 
Posts: n/a
Default Re: in_array

> 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


Reply With Quote
  #3 (permalink)  
Old 10-05-2004
j-marvin
 
Posts: n/a
Default Re: in_array

"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
Reply With Quote
  #4 (permalink)  
Old 10-06-2004
Chung Leong
 
Posts: n/a
Default Re: in_array


"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/


Reply With Quote
  #5 (permalink)  
Old 10-06-2004
j-marvin
 
Posts: n/a
Default Re: in_array

"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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0