Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Scrapping - get Select option values and text via simple html dom

    • 0
    • 1
    • 1
    • 3
    • 0
    • 0
    • 0
    • 0
    • 2.46k
    Comment on it

    Here is the working example to get select box option value and text via Simple html dom. I assume that you have already included simple_html_dom file and have html content in $content variable

      $html = new simple_html_dom(); // Creating html dom object
      $html->load($content);
      $i=0;
      foreach($html->find('select') as $element) { // Getting all select boxes in the html
        if ($element->id == 'getme')  { // if you want to get content of one select box that have id *getme*
              foreach($html->find('option') AS $options) { // find options of this select box 
               $option_val[] = $options->value; // for option value
                $option_txt[] = $options->innertext; // for option text
              }
          }
      }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: