By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,709 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,709 IT Pros & Developers. It's quick & easy.

in_array

P: n/a
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]);
}

}
}


Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> 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
Jul 17 '05 #2

P: n/a
"deko" <ww*******************************@nospam.com> wrote in
news:cP*****************@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
Jul 17 '05 #3

P: n/a

"j-marvin" <cu******@service.boy> wrote in message
news:Xn**************************@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/
Jul 17 '05 #4

P: n/a
"Chung Leong" <ch***********@hotmail.com> wrote in news:zZydnYECa7mBq_
7c******@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

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.