473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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

}
}


Jul 17 '05 #1
4 3222
> 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
"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

"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: AJ Z | last post by:
I am using in_array() to search for a value ("other"), in order to validate a form. If I pass $_POST as the array to search PHP says that it is an invalid datatype. It is an array and if I copy...
2
by: Mountain Man | last post by:
Hi, The in_array function sometimes malfunctions on my computer yielding the error message shown below. The code shown below usually works, but sometimes doesn't. This even happens with the same...
3
by: Phil Powell | last post by:
if (is_array($_POST)) { foreach ($this->getAssocSectionsObjArray($key, $dbAP) as $obj) { print_r($obj); print_r(" in array? "); print_r(in_array($obj, $result)); print_r("<P>"); if...
6
by: Craig Keightley | last post by:
I am trying to compare values of a string entered into an array but having no results, is this possible to achieve: <?php $ids = $row_rsProduct; // A comma separated list of values...
5
by: Phil Powell | last post by:
Here is my array. Plain and simple enumerative array with values being strings. So why does this fail??? print_r(in_array('album', array_keys($boolword))); This produces FALSE or NULL....
4
by: paul brown | last post by:
hello, I have this code sample: class Sexboard extends Master { var $userid; var $errormessage; var $dc_metro = array(20, 46, 51);
3
by: Tom Barnes | last post by:
Check out this code: // Start Code ------------- function test_in_array($val) { $a = array('key' => $val); printf("in_array: %d, value:%s<BR>", in_array('key', $a), $a); } test_in_array(0);...
6
by: Berimor | last post by:
Hi, i've been always used the in_array() function to check availabylity of a value in array. Until today. Simple code: (do not run it tho :) ) <? function getmicrotime(){ list($usec, $sec) =...
3
by: rich | last post by:
I keep getting the error: Warning: in_array(): Wrong datatype for second argument on line 679 here is the code. I declare and fill the array $specprimA = array(); $specprimA=...
3
by: Sonnich | last post by:
The following code is an exact copy of my current code. The idea is to check 2 parts (of string arrays), and add those only once to a common array. I check for existance of an array in a string,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.