$valid = isOffer($specialOffer);
 if ($valid) {
     # break the text down into the deals available
     # $ok = false;
     $str = $specialOffer;
     // functions to parse the special offer string
     #### deal with price ####
     // initialise variables
     $discountAmount = "";
     $originalPrice = "";
     $calcPercentage = "";
     // Get discounted price
     $discountedPrice = getDiscountedPrice($str);
     echo " discountedPrice " . $discountedPrice;
     // Get discount in £
     $discountAmount = getDiscountAmount($str);
     echo "\ndiscountAmount " . $discountAmount;
     // get discount percentage
     $percentageArr = parseTextAround($specialOffer, "%");
     if (isset($percentageArr[0])) {
         $percentage = $percentageArr[0];
     } elseif ($discountedPrice != "") {
         $originalPrice = $discountedPrice + $discountAmount;
         $percentage = calcPercentage($discountAmount, $originalPrice);
     }
     echo "\n percentage " . $percentage;
     // get original price from discount percentage and discounted price
     $originalPrice = $discountedPrice + $discountAmount;
     if ($originalPrice <= $discountedPrice || $discountedPrice == 0) {
         $originalPrice = getOriginalPrice($specialOffer);
         if ($originalPrice == "" || $originalPrice < $discountedPrice || $originalPrice == $discountedPrice || $originalPrice == $discountAmount) {
 $imgURL = "";
 $xtraFeatures = "";
 /*  Get the Data  */
 $specialOffer = "";
 echo $url;
 foreach ($dom->find('div[id=property-specialoffers-box]') as $name) {
     foreach ($name->find('div[id=property-specialoffers-box-content]') as $box) {
         foreach ($box->find('p') as $data) {
             $specialOffer = $data->plaintext;
             // functions to parse the special offer string
             // deal with price
             $discountedPrice = "";
             $discountedPrice = getDiscountedPrice($specialOffer);
             # print_r("discounted price = ".$discountedPrice);
             $discountAmount = "";
             $discountAmount = getDiscountAmount($specialOffer);
             #  print_r("discount amount= ".$discountAmount);
             $originalPrice = "";
             $calcPercentage = "";
             if ($discountedPrice != "") {
                 $originalPrice = $discountedPrice + $discountAmount;
                 #   print_r("original price = ($discountedPrice + $discountAmount)");
                 #   echo $originalPrice;
                 $calcPercentage = calcPercentage($discountAmount, $originalPrice);
                 #  print_r("percentage ".$calcPercentage."%");
             }
             if ($originalPrice == $discountedPrice) {
                 $originalPrice = "";
             }
             // deal with dates
             $getDate = getDate($specialOffer);