Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post

    finding value within array that contains a certain word

    I'm trying to find a value within an array that has the word "fun" in it..
    Therefor I wrote this coding:

    PHP Code:
        <?php 
        $searchword
    ="fun";
    foreach ( 
    $results as $result) { 
       if( 
    substr_count($result$searchword) > ) { 
            echo 
    $result
       } 

     
        
    ?>
    But somehow it doesn't work, as I'm getting the error:

    : Array to string conversion
    What am I doing wrong?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'm not convinced that this is the line the error is tossed from.
    If the $result is an array, than the substr_count would also throw an error. Your error is elsewhere.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •