Search in site contents by php

I use codeigniter.I want search in site contents for several word, that did existence it word in it site or no? if existence a word (of all words) in it site return is FALSE. i tried as following code but get error. How can done it?


<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,''); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $contents = curl_exec($ch); curl_close($ch); $link[] = array("Questions", "Favorite", "myfoodho"); foreach($link as $val){ stristr($contents,$val); // Line 148 //if(){ // return true; //}else{ // return false; //} } ?>


A PHP Error was encountered

Severity: Warning

Message: stristr() [function.stristr]: needle is not a string or an integer

Filename: views/exchange.php

Line Number: 148

-------------Problems Reply------------

When you write

$link[] = array("Questions", "Favorite", "myfoodho");

you are creating an array that contains another array, that is:

0 => array(

In the foreach loop you're just going through the outer array and therefore $val contains the inner array, not the string values.

The solution is to remove the brackets and just assign the array to the variable.

$link = array("Questions", "Favorite", "myfoodho");

Debugging tip: The error message says "needle is not a string or an integer". The "needle" of that function is the second parameter (check the docs if you're not sure). You can then add var_dump( $val ) right before that line to check what the value actually is, if it's not a string or an integer.

Category:php Views:0 Time:2012-01-16
Tags: php

Related post

  • How do I enable Search for Hindi content in mutilingual site in drupal? 2011-05-11

    I have created my site in Hindi as well as in English through i18n module of drupal. My search for English is working successfully, but if I search with respect to Hindi there are no search results. How do I enable the ability to search of Hindi cont

  • keyword search in sites 2011-08-27

    I am planning to build a small social networking site. What is the best way to support keyword search in the content. I am looking for an opinion considering the fact that the contents can grow few TBs in size. thanks, GL --------------Solutions-----

  • coldfusion search across site 2011-09-06

    I'm trying to create a search box that searches across an entire coldfusion site and shows the search results. I've posted my HTML and JS code so far. I'm not that knowledgeable about search or coldfusion, so any help will be greatly appreciated.

  • Best way to migrate site content into a new SharePoint site 2008-12-14

    My team is working on a project to migrate a .com site into SharePoint. After all our look and feel assets, master pages, content types, and page layouts are created, we need to actually "move" the actual site pages into SharePoint. I'm trying to com

  • How do you search by the contents of a tag in simplehtmldom? 2009-07-25

    I am trying to write a web scraper using simplehtmldom. I want to get a tag by searching the contents of the tag. This is the plaintext inside it, not the type of tag. Then once I have the tag by searching for the contents of its plain text I want to

  • In can we search for a content without giving field name..and it will search in all fields that are indexed? 2009-07-27

    In can we search for a content without giving field name..and it will search in all fields that are indexed. --------------Solutions------------- You cannot search for content without giving field name, however you can use MultiFieldQueryP

  • Change the order of the 'Search this site' form in Drupal 2009-12-11

    I need to change the layout of the Search Block in Drupal. It’s currently ordered Search Button > ‘Search this site’ > Search Input but the designs I have want it to be Search Input > ‘Search this site’ > Search Button How do I go around

  • How to automatically update a site with some other site contents.? 2010-03-06

    How to update a site with some other site contents that is getting refreshed often (may be twice in a minute)? --------------Solutions------------- What you're doing is called scraping a website. Try googling on that. Pay particular attention to the

  • How to search the file contents in multiple subversion repositories? 2010-03-08

    I've got multiple SVN repositories of different projects which I would like to search for the same search term / regex, but without checking out or updating each project and doing the search manually on each of them. I'd like to know if it is possibl

  • How to pass multiple dynamic url parameters to my pagination pages when a user searches the site using PHP & MySQL 2010-07-21

    I was wondering how can I pass multiple dynamic url parameters to my pagination pages when a user searches the site using PHP & MySQL in order to display their results? Here is the HTML form. <form action="search.php" method="post"> <inp

  • Custom Google Search with 'search web' and search 'my site' radio buttons 2010-08-22

    I have some experience setting up Google CSEs. I have a request to set up a CSE with an option to 'search the web' or just search the site. I thought it would be very simple, but iver yet to find an example or tutorial. Can anyone point me in the rig

  • How to display other sites content in our sites with out using iframe? 2010-10-02

    How to display other sites content in our sites with out using iframe? Is it possible to load one sites file details in our site with out using the iframe. --------------Solutions------------- You can use the PHP Curl library. It is possible and quit

  • search my site with the help of google in 2011-02-15

    i want to search my site with the help of google. search result will show in my page and no google related icon will show as if user will feel the search functionality is internal. how could i implement in thanks --------------Solutions-----

  • Using PHP include to separate site content 2011-03-03

    I'm looking for advice on the best practice for separating site content up into logical blocks. I want a header and footer that are constant throughout the site, so that if I have several pages of different content, they will all look as below — chan

  • Facebook Like button push down my web site content by 1 pixel after load 2011-05-04

    Like button push down my web site content by 1 pixel after load? What causes this? The website: --------------Solutions------------- The iframe height is causing that. Give a height to #facebook_

  • Permissions in "All Site Content" Page 2011-05-06

    Is there a way to deny the access to the All Site Content" page in SharePoint 2007? I know I can hide the lists and the link to the page, but users can still access via the URL Thanks in advance --------------Solutions------------- You can keep out a

  • use LWP::Simple to get ftp site content in Perl 2011-06-06

    I am having some issue here using LWP::Simple to get ftp site content in Perl. It would work fine if the site used http, but not ftp, for example But in my firefox browser, I can view the content as html. So ho

  • Google Search API site limit 2011-06-20

    According to the Google custom search API's docs: there is a limit of up to 5000 sites that you can search. This is pretty lame. Is there any way around this so that I can search the enti

  • Ignore HTML characters when searching HTML stored content PHP/MySQL? 2011-07-06

    We are storing blocks of HTML content in MySQL (it is formatted text created in CKeditor. Ckeidor adds inline CSS styles to format the text). We are storing the database in a column called "page_content" We want a search feature that allows users to

Copyright (C), All Rights Reserved.

processed in 0.096 (s). 11 q(s)