Advertisement
Guest User

Untitled

a guest
May 24th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.63 KB | None | 0 0
  1.                         case "location":
  2.                         case "zipcode":
  3.                             $location = (string) simplexml_import_dom($node)->asXML();
  4.                             //$location = preg_replace( '/[^[:print:]]/', '',$location);
  5.                             for ($i = 0; $i < strlen($location); $i++) {
  6.                                 echo "<br/>ascii value of " . $location[$i] . " is " . ord($location[$i]);
  7.                                 $code = ord($location[$i]);
  8.                                 if ($code == 194 || $code == 160) {
  9.                                     $location = substr_replace($location, "", $i, 1);
  10.                                     $i--;
  11.                                 }
  12.                             }
  13.                             echo "and now...<br/>";
  14.                             for ($i = 0; $i < strlen($location); $i++) {
  15.                                 echo "<br/>ascii value of " . $location[$i] . " is " . ord($location[$i]);
  16.                                 $code = ord($location[$i]);
  17.                             }
  18.                             echo "<br/>" . htmlspecialchars($location);
  19.                             //echo htmlspecialchars((string) simplexml_import_dom($node)->asXML());
  20.                             echo "<br/>" . preg_replace("/<abbr.*?>/", "", $location);
  21.                             die();
  22.                             $location_with_potential_br_tag = strip_tags((string) simplexml_import_dom($node)->asXML(), '<br>');
  23.                             //echo "<br/><br/>" . htmlspecialchars($location_with_potential_br_tag) . "<br/><br/>";
  24.                             echo "<br/>[WITH TAGS]######" . $location_with_potential_br_tag . "########<br/>";
  25.                             if (strpos($location_with_potential_br_tag, '<br/>') !== false) {
  26.                                 $location_with_no_tags = preg_replace("/<br\/>/", ", ", $location_with_potential_br_tag);
  27.                             } else {
  28.                                 $location_with_no_tags = $location_with_potential_br_tag;
  29.                             }
  30.                             // echo "<br/><br/>" . $location_with_no_tags . "<br/><br/>";
  31.                             // die();
  32.                            
  33.                             //echo "location with xml tags is ###" . htmlspecialchars($location_with_xml_tags) . "###";
  34.                             if ($node_type == "zipcode") {
  35.                                 if (preg_match("/(\d{5})$|(\d{5}-\d{4})$/", $location_with_no_tags, $matches)) {
  36.                                     $zipcode = (string) $matches[1];
  37.                                     return $zipcode;
  38.                                 } else {
  39.                                     echo "no zip code available!?!?!?!?";
  40.                                     die();
  41.                                 }
  42.                             } else {
  43.                                 echo "<br/>[NO TAGS]######" . $location_with_no_tags . "########<br/>";
  44.                                 return $location_with_no_tags;
  45.                             }
  46.                             /*
  47.                             echo "type is " . gettype($location_with_xml_tags);
  48.                             echo "<br/><br/>$ location_with_xml_tags is ###" . $location_with_xml_tags . "###<br/><br/>";
  49.                            
  50.                             $location_with_xml_tags = preg_replace("/<abbr.*?>/", "", $location_with_xml_tags);
  51.                             $location_with_xml_tags = preg_replace("/<\/abbr>/", "", $location_with_xml_tags);
  52.  
  53.                             echo strip_tags($location_with_xml_tags, '<br>');
  54.                             */
  55.                            
  56.                             /*echo "<br/><br/>$ location_with_xml_tags is ###" . strip_tags($location_with_xml_tags) . "###<br/><br/>";
  57.                            
  58.                             $location_with_xml_tags = str_replace("<p>", "", $location_with_xml_tags);
  59.                             //$location_with_xml_tags = preg_replace("/&lt;p&gt;/", "", $location_with_xml_tags);
  60.                             // echo "<pre>";
  61.                             // print_r($matches);
  62.                             // echo "</pre>";
  63.                             echo "<br/><br/>$ location_with_xml_tags is ###" . $location_with_xml_tags . "###<br/><br/>";
  64.                            
  65.                             */
  66.                             // die();
  67.                             // if (preg_match("/.*/", $location_with_xml_tags, $matches)) {
  68.                                 ////strip all tags except the one br tag
  69.                                 // echo "SUCCESSSSSSSSSSSSSSSSSSSSS";
  70.                                 // echo "AAA" . $matches[0] . "BBB<br/>";
  71.                                 // echo "<pre>";
  72.                                 // print_r($matches);
  73.                                 // echo "</pre>";
  74.                                 // die();
  75.                                 // $location_with_br_tag_only = $matches[1] . $matches[2] . $matches[3];
  76.                                 // return $location_with_br_tag_only;
  77.                             // } else {
  78.                                 // echo "matches is ";
  79.                                 // print_r($matches);
  80.                                 // echo "no location!!?!?!?";
  81.                                 // die();
  82.                             // }
  83.                             break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement