title: PHP Retry Script until Success or Error
body: <p>Thank you for taking the time to read this and I will appreciate every single response no mater the quality of content. :)</p>
  
  <p>I'm trying to create a php script which retries another php script up to 3 times until an error message is displayed. I'm thinking perhaps this could be done using a php loop? If the code works successfully the first time, then there is no need for it to retry 3 times, however, if it doesn't work the first time, then it should retry the php script up to 3 times untill an error message is displayed.</p>
  
  <p>Using php coding, I've managed to make a script which grabs/fetches content from another location using "file_get_contents" and thereafter gives each word/data a php variable. All this was done by getting help from other members on stackoverflow (which I extremely appreciate). The code below is what does it all:</p>
  
  <pre><code>$searchdata = file_get_contents('http://www.example.com');
  
  list($no1, $no2, $no3, $no4, $no5, 
       $no6, $no7, $no8, $no9) = explode(" ", $searchdata);
  </code></pre>
  
  <p>So, I'd like to add some sort of loop which retries this script up to 3 times; if it doesn't work the first time.</p>
  
  <p>To determine whether the script works the first/second/third time or not, the text "#endofscript" or "failure" should be found when using "file_get_contents". The text "#endofscript" should be on the variable "$no9" and the text "failure" should be on the variable "$no2". If anything else is found other than "#endofscript" or "failure" that should be counted as an error and should be looped till found. If it still isn't found after the third try, could an error message be displayed? Such as "Error - Please try again".</p>
  
  <p>Thank you for all your assistance and I will appreciate each and every single reply. If you need more details, please feel free to ask. :) And again, I'm really grateful for this. :)</p>