Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "location":
- case "zipcode":
- $location = (string) simplexml_import_dom($node)->asXML();
- //$location = preg_replace( '/[^[:print:]]/', '',$location);
- for ($i = 0; $i < strlen($location); $i++) {
- echo "<br/>ascii value of " . $location[$i] . " is " . ord($location[$i]);
- $code = ord($location[$i]);
- if ($code == 194 || $code == 160) {
- $location = substr_replace($location, "", $i, 1);
- $i--;
- }
- }
- echo "and now...<br/>";
- for ($i = 0; $i < strlen($location); $i++) {
- echo "<br/>ascii value of " . $location[$i] . " is " . ord($location[$i]);
- $code = ord($location[$i]);
- }
- echo "<br/>" . htmlspecialchars($location);
- //echo htmlspecialchars((string) simplexml_import_dom($node)->asXML());
- echo "<br/>" . preg_replace("/<abbr.*?>/", "", $location);
- die();
- $location_with_potential_br_tag = strip_tags((string) simplexml_import_dom($node)->asXML(), '<br>');
- //echo "<br/><br/>" . htmlspecialchars($location_with_potential_br_tag) . "<br/><br/>";
- echo "<br/>[WITH TAGS]######" . $location_with_potential_br_tag . "########<br/>";
- if (strpos($location_with_potential_br_tag, '<br/>') !== false) {
- $location_with_no_tags = preg_replace("/<br\/>/", ", ", $location_with_potential_br_tag);
- } else {
- $location_with_no_tags = $location_with_potential_br_tag;
- }
- // echo "<br/><br/>" . $location_with_no_tags . "<br/><br/>";
- // die();
- //echo "location with xml tags is ###" . htmlspecialchars($location_with_xml_tags) . "###";
- if ($node_type == "zipcode") {
- if (preg_match("/(\d{5})$|(\d{5}-\d{4})$/", $location_with_no_tags, $matches)) {
- $zipcode = (string) $matches[1];
- return $zipcode;
- } else {
- echo "no zip code available!?!?!?!?";
- die();
- }
- } else {
- echo "<br/>[NO TAGS]######" . $location_with_no_tags . "########<br/>";
- return $location_with_no_tags;
- }
- /*
- echo "type is " . gettype($location_with_xml_tags);
- echo "<br/><br/>$ location_with_xml_tags is ###" . $location_with_xml_tags . "###<br/><br/>";
- $location_with_xml_tags = preg_replace("/<abbr.*?>/", "", $location_with_xml_tags);
- $location_with_xml_tags = preg_replace("/<\/abbr>/", "", $location_with_xml_tags);
- echo strip_tags($location_with_xml_tags, '<br>');
- */
- /*echo "<br/><br/>$ location_with_xml_tags is ###" . strip_tags($location_with_xml_tags) . "###<br/><br/>";
- $location_with_xml_tags = str_replace("<p>", "", $location_with_xml_tags);
- //$location_with_xml_tags = preg_replace("/<p>/", "", $location_with_xml_tags);
- // echo "<pre>";
- // print_r($matches);
- // echo "</pre>";
- echo "<br/><br/>$ location_with_xml_tags is ###" . $location_with_xml_tags . "###<br/><br/>";
- */
- // die();
- // if (preg_match("/.*/", $location_with_xml_tags, $matches)) {
- ////strip all tags except the one br tag
- // echo "SUCCESSSSSSSSSSSSSSSSSSSSS";
- // echo "AAA" . $matches[0] . "BBB<br/>";
- // echo "<pre>";
- // print_r($matches);
- // echo "</pre>";
- // die();
- // $location_with_br_tag_only = $matches[1] . $matches[2] . $matches[3];
- // return $location_with_br_tag_only;
- // } else {
- // echo "matches is ";
- // print_r($matches);
- // echo "no location!!?!?!?";
- // die();
- // }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement