dechamp Posted October 15, 2009 Share Posted October 15, 2009 K so i did a search for this but could not find it. I have a search script for my site. Right now the way it works is that if you search for multiple words such as "Business cards" I basically have it check a database for each word. So it does a search for "Business" and then a search for "Cards" and in the database it has how many occurrences each word has per page. exp below. The below is if i have it print but I can put it in to an array as well. So I basically am using the page url (i swap the url for xxxxx) as the key and the occurrences as the value. well i want to take the multiple arrays and make them a single array with the key still being the url and the value being added together. That way i can display the results as a single result. so instead of results for "business" and one for "cards" it would show the combined results for "Business Cards". WHAT I GET NOW FOR AN ARRAY Array ( [0] => Array ( [xxxxx/info] => 68 [xxxxx/work] => 12 ) [1] => Array ( [xxxxx/info] => 30 [xxxxxx/work] => 4 ) ) WHAT I WANT TO GET FOR AN ARRAY Array ( [xxxxx/info] => 98 [xxxxx/work] => 16 ) WHAT I GET NOW IF I PRINT IT. Search results for 'business': 1. xxxx/info (occurrences: 68) 2. xxxx/work (occurrences: 12) query executed in 0.048 seconds. Search results for 'cards': 1. xxxxx/info (occurrences: 30) 2. xxxxx/work (occurrences: 4) query executed in 0.046 seconds. Link to comment https://forums.phpfreaks.com/topic/177815-merging-arrays-and-adding-the-values-together/ Share on other sites More sharing options...
mrMarcus Posted October 15, 2009 Share Posted October 15, 2009 isn't that creating misleading search results, since it's returning results for 'cards' and results for 'business', each of which not necessarily having anything to do with 'Business Cards'? i believe you have a fundamental error .. just my opinion though. Link to comment https://forums.phpfreaks.com/topic/177815-merging-arrays-and-adding-the-values-together/#findComment-937598 Share on other sites More sharing options...
dechamp Posted October 15, 2009 Author Share Posted October 15, 2009 ha ha you know I never thought of it that way, good point. Hmmmm ok so then i guess what i really need is a better search engine script. any suggestions? Link to comment https://forums.phpfreaks.com/topic/177815-merging-arrays-and-adding-the-values-together/#findComment-937599 Share on other sites More sharing options...
mrMarcus Posted October 15, 2009 Share Posted October 15, 2009 it really depends on how your system is setup, or will be setup. what kind of site do you have? what will people be searching for, articles? products? 'cause then it's all how you set things up in the db to get the best results possible. provide a little more info on your site and i'll see if i can help. Link to comment https://forums.phpfreaks.com/topic/177815-merging-arrays-and-adding-the-values-together/#findComment-937614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.