Replace UTF string - php

I have a data set which looks like this:
701 B STREET
SUITE C
SAN DIEGO,CA 92101
¥************CAR INFO******************
¥ZE CD-1337966
¥ZI CD-D515000 FOR MONTHLY RATES PLS CALL
¥AVIS MINI LEASE PLS CALL 800-524-9000 EXT 3034
¥CONTACT EMAIL CANDACE.GREER.AT.CENDANT.COM
¥ANY OTHER CAR COMPANY USED OTHER THAN THE ABOVE
¥WILL NOT REIMBURSED FOR THE COST OF INSURANCE
I want to replace the Yen symbol.
I tried this :
$data_result=str_replace(chr(0xC2).chr(0xA5),"",$data);
Still could not replace the expression.
Thank you guys in advance.

How about:
$str = '701 B STREET
SUITE C
SAN DIEGO,CA 92101
¥************CAR INFO******************
¥ZE CD-1337966
¥ZI CD-D515000 FOR MONTHLY RATES PLS CALL
¥AVIS MINI LEASE PLS CALL 800-524-9000 EXT 3034
¥CONTACT EMAIL CANDACE.GREER.AT.CENDANT.COM
¥ANY OTHER CAR COMPANY USED OTHER THAN THE ABOVE
¥WILL NOT REIMBURSED FOR THE COST OF INSURANCE';
$str = preg_replace('/¥/u', '', $str);
echo $str;
output:
701 B STREET
SUITE C
SAN DIEGO,CA 92101
************CAR INFO******************
ZE CD-1337966
ZI CD-D515000 FOR MONTHLY RATES PLS CALL
AVIS MINI LEASE PLS CALL 800-524-9000 EXT 3034
CONTACT EMAIL CANDACE.GREER.AT.CENDANT.COM
ANY OTHER CAR COMPANY USED OTHER THAN THE ABOVE
WILL NOT REIMBURSED FOR THE COST OF INSURANCE

Related

Capitalize title selectively

I have a list of headings entered like below:
junior suite for sale
Beautiful eCommerce office
d'Landon Property for rent
stunning House FOR SALE
To make things consistent, we apply text-transform: capitalize to the titles, so that the front-end view would be consistent:
Junior Suite For Sale
Beautiful ECommerce Office
D'Landon Property For Rent
Stunning House For Sale
However, this results in some incorrect names like eCommerce, d'Landon, which is not desirable. Is there anyway to fix this, hopefully without relying on backend logic change (I use PHP by the way)?
Expected result:
Junior Suite For Sale
Beautiful eCommerce Office
d'Landon Property For Rent
Stunning House For Sale
There is no way to do this in CSS alone, but in case javascript is an option as mentioned in my comment, here is a snippet:
let pList = document.getElementsByTagName('h2');
let blackList = /eCommerce|d'Landon/g
for(let i=0; i< pList.length; i++) {
let text = pList[i].textContent;
let newText = text.replace(blackList, '<span class="no-cap">$&<span>');
pList[i].innerHTML = newText;
}
h2 {
text-transform: capitalize;
}
.no-cap {
text-transform: none;
}
<h2>junior suite for sale</h2>
<h2>Beautiful eCommerce office</h2>
<h2>d'Landon Property for rent</h2>
<h2>stunning House FOR SALE</h2>
This is how I would do it in PHP. I would write a bunch of regular expressions to figure out which ones are not the way I want. Then replace the ones I don't want with uppercase and lowercase.
Here for example, in the code below, if all the letters are capital in a word, it is converted. If there are any small letters after the first letter in a word, it isn't converted.
<?php
$titles = ["junior suite for sale",
"Beautiful eCommerce office",
"d'Landon Property for rent",
"stunning House FOR SALE"];
function smart_title($title){
$newtitle = [];
foreach(preg_split("/ /", $title) as $word){
if(preg_match("/^[A-Z]+$/", substr($word, 1, strlen($word)))){
array_push($newtitle, strtoupper(substr($word, 0, 1)).strtolower(substr($word, 1, strlen($word))));
}else if(preg_match("/[A-Z]/", substr($word, 1, strlen($word)))){
array_push($newtitle, $word);
}else{
array_push($newtitle, strtoupper(substr($word, 0, 1)).strtolower(substr($word, 1, strlen($word))));
}
}
return join(" ", $newtitle);
}
foreach($titles as $title){
echo smart_title($title)."\n";
}
?>
Try it out here: http://sandbox.onlinephpfunctions.com/code/450141f600bb5497b46e48b4f96738e811cd3617 .
Result is:
Junior Suite For Sale
Beautiful eCommerce Office
d'Landon Property For Rent
Stunning House For Sale

parsing an XML file with extra content at the end

Hello Stack Exchange community,
I'm trying to make a Equifax API to get credit information (don't worry the data you see is all dummy data). I'm using their XML input. I am receiving the XML response just fine, but for some god awful reason the equifax developers decided to add some 'extra' content at the end of outside of the XML tags.
This essentially makes the xml un-parseable in php. Is there a way to strip out the extra content at the end?
Here is the XML response. Look after the closing EfxTransmit tag
<?xml version="1.0" encoding="UTF-8"?>
<EfxTransmit>
<EfxReport requestNumber="1" reportId="USConsumerCreditReport">
<USDecisionPowerExpressReports>
<USDecisionPowerExpressReport subjectType="Subject" multipleNumber="1">
<USMasterHeader>
<CustomerReferenceNumber>EFX QA</CustomerReferenceNumber>
<CustomerNumber>999KI00553</CustomerNumber>
<ECOAInquiryType>I</ECOAInquiryType>
<DateOfRequest format="MM/DD/CCYY">02/23/2017</DateOfRequest>
<EquifaxReferenceNumber>187388032</EquifaxReferenceNumber>
</USMasterHeader>
<USConsumerCreditReport subjectType="Subject" multipleNumber="1">
<USHeader>
<Request>
<CustomerReferenceNumber>EFX QA</CustomerReferenceNumber>
<CustomerNumber>999KI00553</CustomerNumber>
<ConsumerReferralCode>024</ConsumerReferralCode>
<ECOAInquiryType>I</ECOAInquiryType>
<NumberOfMonthsToCountInquiries>Last 24 Months</NumberOfMonthsToCountInquiries>
<NumberOfMonthsToCountDelinquencies>Last 6 Years, 11 Months</NumberOfMonthsToCountDelinquencies>
</Request>
<CreditFile>
<HitCode code="1" description="Hit"/>
<FileSinceDate format="MM/DD/CCYY">04/16/2003</FileSinceDate>
<DateOfLastActivity format="MM/DD/CCYY">01/24/2017</DateOfLastActivity>
<DateOfRequest format="MM/DD/CCYY">02/23/2017</DateOfRequest>
<Identityscans>
<Identityscan code="8" description="Unable to perform telephone validation due to insufficient telephone input"/>
</Identityscans>
<AddressDiscrepancyIndicator>N</AddressDiscrepancyIndicator>
<CreateCode>2</CreateCode>
<FileStatus1>016</FileStatus1>
<FileStatus2>242</FileStatus2>
<FileStatus3>004</FileStatus3>
<BureauCode>244</BureauCode>
</CreditFile>
<Subject>
<SubjectName>
<LastName>DGNNLXZ</LastName>
<FirstName>CHANITA</FirstName>
<MiddleName>S</MiddleName>
</SubjectName>
<SubjectId>
<SubjectSSN>66639074</SubjectSSN>
<DateOfBirth format="MM/DD/CCYY">08/17/1988</DateOfBirth>
</SubjectId>
</Subject>
</USHeader>
<USAddresses>
<USAddress code="CA" description="Current Address">
<ParsedStreetAddress>
<StreetNumber>4338</StreetNumber>
<StreetName>W POTOMAC</StreetName>
<StreetType>AVE</StreetType>
</ParsedStreetAddress>
<City>CHICAGO</City>
<State>IL</State>
<PostalCode>60651</PostalCode>
<DateAddressFirstReported format="MM/CCYY">07/2015</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">02/2017</DateAddressLastReported>
</USAddress>
<USAddress code="FA" description="Former Address">
<ParsedStreetAddress>
<StreetNumber>1301</StreetNumber>
<StreetName>BRUMMEL</StreetName>
<StreetType>ST APT 8</StreetType>
</ParsedStreetAddress>
<City>EVANSTON</City>
<State>IL</State>
<PostalCode>60202</PostalCode>
<DateAddressFirstReported format="MM/CCYY">04/2015</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">04/2015</DateAddressLastReported>
</USAddress>
<USAddress code="F2" description="Second Former Address">
<ParsedStreetAddress>
<StreetNumber>1208</StreetNumber>
<StreetName>W JEFFERSON</StreetName>
<StreetType>ST APT C</StreetType>
</ParsedStreetAddress>
<City>SPRINGFIELD</City>
<State>IL</State>
<PostalCode>62702</PostalCode>
<DateAddressFirstReported format="MM/CCYY">06/2014</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">06/2014</DateAddressLastReported>
</USAddress>
</USAddresses>
<USEmployments>
<USEmployment code="ES" description="Last Reported Employment">
<Occupation>CORRECTION OFF</Occupation>
<Employer>MACON STATE PRISON</Employer>
</USEmployment>
</USEmployments>
<USFICO>
<FICOScore>00650</FICOScore>
<ScoreReasons>
<ScoreReason code="00038" description="Serious delinquency, and derogatory public record or collection filed" number="1"/>
<ScoreReason code="00010" description="Prop of balances to credit limits is too high on bank rev or other rev accts" number="2"/>
<ScoreReason code="00018" description="Number of accounts with delinquency" number="3"/>
<ScoreReason code="00014" description="Length of time accounts have been established" number="4"/>
</ScoreReasons>
<ScoreIndicator code="J" description="FICO Score 5 based on Equifax Data (NF)"/>
</USFICO>
<USIdentificationSSN>
<MDBSubjectSSN>666390749</MDBSubjectSSN>
<InquirySubjectSSN>666390749</InquirySubjectSSN>
<InquirySSNDateIssued>1992</InquirySSNDateIssued>
<InquirySSNStateIssued>GA</InquirySSNStateIssued>
</USIdentificationSSN>
</USConsumerCreditReport>
<USDecisionPowerExpressSegment>
<ConsumerDisclosureIndicator></ConsumerDisclosureIndicator>
<ReportTextMessage>OFFER C</ReportTextMessage>
<SSNVarianceIndicator></SSNVarianceIndicator>
<DPExpressProducts>
<DPExpressProduct number="1">
<Description>A</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="2">
<Description>B</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="3">
<Description>C</Description>
<ApprovalIndicator>Y</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="4">
<Description>D</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
</DPExpressProducts>
</USDecisionPowerExpressSegment>
</USDecisionPowerExpressReport>
</USDecisionPowerExpressReports>
<USPrintImage><![CDATA[TRANSACTION NUMBER: 187388032
BRANCH NUMBER: EFX QA
NO SUBSTANTIAL DIFFERENCE WAS FOUND BETWEEN INQUIRY ADDRESS(ES) AND
THE EXISTING CREDIT FILE ADDRESS(ES).
Product Approval Limit Misc
Indicator
C Y
OFFER C
**** Credit Report Information ****************************************
Equifax Information Services LLC
P O Box 740241, Atlanta, GA 30374-0241
800/685-1111
Name: CHANITA S DGNNLXZ Since: 04162003 SSN: 66639074
DOB/Age: 08/17/1988 Last Activity: 01242017 Report Date: 02232017
072015 4338 W POTOMAC AVE, CHICAGO IL 60651
042015 1301 BRUMMEL ST APT 8, EVANSTON IL 60202
062014 1208 W JEFFERSON ST APT C, SPRINGFIELD IL 62702
Employment information:
MACON STATE PRISON, CORRECTION OFF
Identity Scan: UNABLE TO PERFORM TELEPHONE VALIDATION DUE TO INSUFFICIENT TELEPHONE INPUT.
Customer Reference: EFX QA
ADI: NO SUBSTANTIAL DIFFERENCE WAS FOUND BETWEEN INQUIRY ADDRESS(ES) AND
THE EXISTING CREDIT FILE ADDRESS(ES).
FICO Score 5-EFX-N: 00650 00038 00010 00018 00014 Reject:
Serious delinquency, and derogatory public record or collection filed
Prop of balances to credit limits is too high on bank rev or other rev accts
Number of accounts with delinquency
Length of time accounts have been established
END OF REPORT
]]>
</USPrintImage>
</EfxReport>
</EfxTransmit>
FULLEFX QA 999KI005530241I02 1041620030124201702232017DGNNLXZ CHANITA S 66639074 08171988 0010101000000010000000000000000000000000000000000000000000000010000000000010000000100000000000000000000000000000000000000N I 2016242004244 8CA4338 W POTOMAC AVE CHICAGO IL60651 072015 T022017 FA1301 BRUMMEL ST APT 8 EVANSTON IL60202 042015 T042015 F21208 W JEFFERSON ST APT C SPRINGFIELD IL62702 062014 T062014 ESCORRECTION OFF MACON STATE PRISON CP0065000038000100001800014 J SS 666390749 6663907491992GA DP A N B N C Y D N

How to spit out a headline, photo(s) and story from news article using PHP

Ok so I am fairly lost and frustrated, I've been reading and working on this for hours and when I feel like I make progress...I find out I really haven't.
Problem:Take a news article from some place like cnn.com and make a php web application that spits out the headline, the story, and any photos. Make sure to strip all HTML tags.
Must use classes, constructors, and CANNOT use 3rd party libraries, native PHP is ok.
So here is the article I am working on
http://www.cnn.com/2015/11/18/us/delmarva-peninsula-squirrel-endangered-species-feat/index.html
Where I left last from frustration is this, it pulls out everything I need, but leaves the raw code showing too.
$url='http://www.cnn.com/2015/11/18/us/delmarva-peninsula-squirrel-endangered-species-feat/index.html';
$element = file_get_contents($url);
echo strip_tags($element , "<h1>, <img>, <p>");
I had this at one point as well
//Class Structure
class ThisIsMyClass {
public $aHTMLContent = 'HTMLContent';
public $aHeader = 'Header';
public $aPictures = 'Pictures';
}
$ThisIsMyClass = new ThisIsMyClass;
//Title For Page
$element = 'Header'
$ThisIsMyClass->$element=file_get_contents("http://www.cnn.com/tech", 20);
preg_match("/<title>(.*)</title>/i", $html, $match);
$title = $match[1];
echo $element . '<br>';
//HTML Content
$element2 = 'HTMLContent'
$ThisIsMyClass->$element2=getHTML("http://www.cnn.com/tech");
echo $element2 . '<br>';
//Get all images from page
$element3 = 'Pictures';
foreach($element2->find"img" as $element3)
echo $element3->src . '<br>';
?>
I see a ton of "use curl" but since curl is 3rd party I cannot use it. I have seen pulling the title specific, but the actual title is in a meta tag. I followed a couple examples on here for extracting meta tags, but I get errors that apparently no other post gets.
Please help! I need to finish this tonight, I have done my due diligence on it and I just do not know where else to look.
Ok...so I've spent the last two hours trying to look at how to add a class and constructor to this where it makes sense....
Every example I can find is the stereotypical
class human
{
function talk{
echo "Hello"}
}
etc....I am having trouble seeing how this relates to what I have going on. I am basically going off of the code structure that Chris85 posted below. I do not see how the info from the code below involves classes and a constructor....can someone help with some hints, examples, or a good tutorial that involves something a little closer to what I am working with??
Here's a rough example using the DOM parser to output all h1, img, and p elements content.
$url='http://www.cnn.com/2015/11/18/us/delmarva-peninsula-squirrel-endangered-species-feat/index.html';
$string = file_get_contents($url);
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($string);
libxml_use_internal_errors(false);
output_these_elements(array('h1', 'img', 'p'), $doc);
function output_these_elements($elements, $doc) {
foreach($elements as $element) {
echo $element . "\n\n";
$domelements = $doc->getElementsByTagName($element);
foreach($domelements as $domelement) {
if($element == 'img') {
echo $domelement->getAttribute('src') . "\n";
} else {
echo $domelement->nodeValue . "\n";
}
}
}
}
Output:
h1
Nuts to you! Squirrel gets off endangered species list
img
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110249-01-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110527-02-animals-endangered-species-restricted-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110554-03-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110627-04-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110842-05-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110903-06-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110938-07-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111005-08-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111029-09-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111059-10-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111206-11-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111225-12-animals-endangered-species-super-169.jpg
data:image/gif;base64,R0lGODlhEAAJAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAQAAkAAAIKlI+py+0Po5yUFQA7
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111242-13-animals-endangered-species-super-169.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110249-01-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110527-02-animals-endangered-species-restricted-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110554-03-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110627-04-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110842-05-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110903-06-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118110938-07-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111005-08-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111029-09-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111059-10-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111206-11-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111225-12-animals-endangered-species-small-11.jpg
http://i2.cdn.turner.com/cnnnext/dam/assets/151118111242-13-animals-endangered-species-small-11.jpg
p
By Todd Leopold, CNN
Updated 3:54 PM ET, Wed November 18, 2015
(CNN)Forget about gathering nuts. A rare species of squirrel has gathered new life.
The Delmarva Peninsula fox squirrel, one of the animals on the original endangered species list, is now no longer at risk of extinction, says the U.S. Department of the Interior.
"The fox squirrel's return to this area, rich with farmland and forest, marks not only a major win for conservationists and landowners, but also represents the latest in a string of success stories that demonstrate the Endangered Species Act's effectiveness," Interior official Michael Bean said from Prime Hook National Wildlife Refuge in Milton, Delaware, according to a Department of the Interior statement.
The squirrel -- native to Delaware and coastal Maryland and Virginia (DelMarVa, get it?) -- will be officially removed from the list in December.
The Delmarva Peninsula fox squirrel was one of 78 species listed under the Endangered Species Preservation Act in 1967, the first year the list appeared. It continued on the successor list of Threatened and Endangered Wildlife under the Endangered Species Act, passed in 1973.
It's one of 30 species to have been delisted, according to the Interior Department. Others include the peregrine falcon, the American alligator and the national bird of the United States, the bald eagle.
Not all species make it, despite being listed. The Santa Barbara song sparrow was noted as extinct in 1983 despite 10 years on the list. Also considered extinct are the longjaw cisco, a fish once found in the Great Lakes; the Mariana mallard, a duck native to the Mariana Islands; and the Caribbean monk seal, a once-common Gulf of Mexico seal -- Columbus recorded their existence in 1494 -- that was delisted in 2008 after an exhaustive search.
The Delmarva Peninsula fox squirrel also had a difficult climb back to its current population. Larger than your average suburban nut-hoarder, it was widely found in the rural areas of the Delmarva Peninsula, a landmass between the Chesapeake Bay and the Atlantic Ocean.
But decades of development and overhunting, starting in the 1950s, limited the fox squirrel's habitat and threatened its existence.
However, "since listing, the squirrel's range has increased from four to 10 counties, and a population of up to 20,000 squirrels now covers 28 percent of the Delmarva Peninsula, primarily in Maryland," the Interior Department's statement observed. (No word on whether Atlanta's Inman Park Squirrel Census contributed to the counting.)
Still, just because the squirrel is no longer endangered, don't expect to head out immediately and start grabbing a few for dinner. According to a fact sheet, "Deliberate killing of any animal is permissible only during an open hunting season defined under state law in Maryland, Delaware and Virginia." Those states haven't decided on any details.
Not bad, Delmarva Peninsula fox squirrel. You're out of the woods -- that is, if you wanted to leave.

JSON KEY/VALUE to PHP variable

I'll get right to the point.
I'm trying to save data retrieved from an API using the following:
$i=0;
foreach($results->results as $product){
$products[$i]['pid'] = $product->listing_id;
$products[$i]['title'] = $product->title;
$products[$i]['url'] = $product->url;
$products[$i]['price'] = $product->price;
$products[$i]['quantity'] = $product->quantity;
$products[$i]['endtime'] = $product->ending_tsz;
$products[$i]['thumb'] = $product->results.Images[url_75x75];
Here is the JSON request:
{
"count":163,
"results":[
{
"listing_id":118973432,
"state":"active",
"user_id":27549667,
"category_id":68894752,
"title":"Funny I Love You Valentines Card - I Heart you Even More then a Nerd Loves Starwars - Adult Funny Humor Greeting Cards",
"description":"You know how much Nerds be loving the Star Wars , this Valentines day show the one you love that you love them even more then that - The perfect greeting card for that special someone!\r\n\r\nGUARANTEED CHRISTMAS DELIVERY - Place your orders by 12\/19 and get it by Christmas Eve - Upgraded Two Shipping available starting at $5, just contact us to upgrade\r\n\r\nDetails:\r\n\r\n- Outside Message: I love you even more then a nerd loves Starwars\r\n- Inside Message: Blank Inside\r\n- Size A7 (5x7)\r\n- Matching White Envelope included \r\n- Packaged in a cello sleeve for protection in transit\r\n\r\nWe will gladly ship to your recipient! Just specify a ship to address and any special message in "notes to seller" at checkout. Need a Custom Card, Magnet or keychain, we do that too!\r\n\r\nShipping:\r\nUS S&H is $2-Ships within 1 business day. Please allow 2-5 business days for delivery.\r\nIntl S&H is $4 - Ships within 1 business day - Please allow 7-10 business days for delivery.\r\n\r\nBuy MORE and SAVE on shipping! Express shipment is available to most US cities contact us for price and details.\r\n\r\nFor More Rude, crude and downright funny greeting cards, novelty gifts and prints, visit our Etsy store and browse a large selection single cards, greeting card sets, prints and more totally edgy, racy, adult, crass, lude, perverted and all things nasty!\r\nimjustsayininc.etsy.com",
"creation_tsz":1422565585,
"ending_tsz":1432929985,
"original_creation_tsz":1356746393,
"last_modified_tsz":1422565585,
"price":"4.00",
"currency_code":"USD",
"quantity":3,
"tags":[
"funny card",
"greeting card",
"novelty card",
"mature card",
"adult card",
"cards",
"funny cards",
"relationship card",
"love card",
"i love you card",
"valentines cards",
"funny valentine",
"valentines day card"
],
"category_path":[
"Paper Goods",
"Cards",
"Valentine"
],
"category_path_ids":[
69150367,
69152963,
68894752
],
"materials":[
"Papaer",
"Ink",
"Envelope"
],
"shop_section_id":12656719,
"featured_rank":null,
"state_tsz":1421921498,
"url":"https:\/\/www.etsy.com\/listing\/118973432\/funny-i-love-you-valentines-card-i-heart?utm_source=massetsy&utm_medium=api&utm_campaign=api",
"views":764,
"num_favorers":102,
"shipping_template_id":null,
"processing_min":1,
"processing_max":1,
"who_made":"i_did",
"is_supply":"false",
"when_made":"2010_2015",
"is_private":false,
"recipient":"unisex_adults",
"occasion":"valentines",
"style":null,
"non_taxable":false,
"is_customizable":true,
"is_digital":false,
"file_data":"",
"language":"en-US",
"has_variations":false,
"used_manufacturer":false,
"Images":[
{
"listing_image_id":410447372,
"hex_code":"C1AFB1",
"red":193,
"green":175,
"blue":177,
"hue":353,
"saturation":9,
"brightness":75,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":1,
"url_75x75":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_75x75.410447372_sjo4.jpg",
"url_170x135":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_170x135.410447372_sjo4.jpg",
"url_570xN":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_570xN.410447372_sjo4.jpg",
"url_fullxfull":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_fullxfull.410447372_sjo4.jpg",
"full_height":737,
"full_width":600
},
{
"listing_image_id":402927400,
"hex_code":"897761",
"red":137,
"green":119,
"blue":97,
"hue":33,
"saturation":29,
"brightness":53,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":2,
"url_75x75":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_75x75.402927400_e80x.jpg",
"url_170x135":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_170x135.402927400_e80x.jpg",
"url_570xN":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_570xN.402927400_e80x.jpg",
"url_fullxfull":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_fullxfull.402927400_e80x.jpg",
"full_height":800,
"full_width":986
},
{
"listing_image_id":402923983,
"hex_code":"C8C1C0",
"red":200,
"green":193,
"blue":192,
"hue":8,
"saturation":4,
"brightness":78,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":3,
"url_75x75":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_75x75.402923983_snri.jpg",
"url_170x135":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_170x135.402923983_snri.jpg",
"url_570xN":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_570xN.402923983_snri.jpg",
"url_fullxfull":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_fullxfull.402923983_snri.jpg",
"full_height":440,
"full_width":640
}
]
}
],
"params":{
"limit":"1",
"offset":0,
"page":null,
"shop_id":"imjustsayininc",
"keywords":null,
"sort_on":"created",
"sort_order":"down",
"min_price":null,
"max_price":null,
"color":null,
"color_accuracy":0,
"tags":null,
"category":null,
"translate_keywords":"false",
"include_private":0
},
"type":"Listing",
"pagination":{
"effective_limit":1,
"effective_offset":0,
"next_offset":1,
"effective_page":1,
"next_page":2
}
}
What I'm trying to do is pull all values from the image field where it shows an image URL (url_75x75,url_170x135,url_570xN & url_fullxfull).
I seem to be stuck only on the importing of the images. They seems to be in an array and I can't figure out how to implement pulling them like I do the rest of the content.
I've spent roughly 3 days searching, trying and failing at doing this.
I was successful when I had the Json request split up into separate requests but recently learned I could include images into one JSON request which is the method I am currently trying.
How can I do this?
I'm pretty new to PHP and I'm even newer at JSON so please be descriptive as possible and try not to overload me with complex ways I could do this, thank you.
results is an array of objects, so is Images
I didn't test it but I think something like this should be able to retrieve the first image of the first result:
$product->results[0]->Images[0]->url_75x75
In your code, this is obviously wrong:
$product->results.Images[url_75x75]
Javascript with PHP syntax mixed together? ;-)

Parse SOAP response in php

I'm dealing with a SOAP client response for a flight booking application, I successfully got the response, See the response below:
<arzoo__response>
<Response__Depart>
<OriginDestinationOptions>
<OriginDestinationOption>
<FareDetails>
<ChargeableFares>
<ActualBaseFare>4850</ActualBaseFare>
<Tax>4267</Tax>
<STax>31</STax>
<SCharge>0</SCharge>
<TDiscount>0</TDiscount>
<TPartnerCommission>0</TPartnerCommission>
</ChargeableFares>
<NonchargeableFares>
<TCharge>0</TCharge>
<TMarkup>0</TMarkup>
<TSdiscount>0</TSdiscount>
</NonchargeableFares>
</FareDetails>
<FlightSegments>
<FlightSegment>
<AirEquipType>321</AirEquipType>
<ArrivalAirportCode>DEL</ArrivalAirportCode>
<ArrivalDateTime>2013-05-20T08:00:00</ArrivalDateTime>
<DepartureAirportCode>BOM</DepartureAirportCode>
<DepartureDateTime>2013-05-20T06:00:00</DepartureDateTime>
<FlightNumber>601</FlightNumber>
<OperatingAirlineCode>AI</OperatingAirlineCode>
<OperatingAirlineFlightNumber>601</OperatingAirlineFlightNumber>
<RPH></RPH>
<StopQuantity>0</StopQuantity>
<airLineName>Air India</airLineName>
<airportTax>4267</airportTax>
<imageFileName>http://live.arzoo.com/FlightWS/image/AirIndia.gif</imageFileName>
<viaFlight></viaFlight>
<BookingClass>
<Availability>4</Availability>
<ResBookDesigCode>U</ResBookDesigCode>
</BookingClass>
<BookingClassFare>
<adultFare>4850</adultFare>
<bookingclass>U</bookingclass>
<classType>Economy</classType>
<farebasiscode>fjyS3YyUlEusLfJ4bwgPvQ==</farebasiscode>
<Rule>This fare is Refundable <br> Baggage : 25K<br>Booking Class : U|Re-Schedule Charges: Rs. 750 per sector + Fare difference (If any) +admin fee 500 + Service Fee of Rs. 250 Sector .|Cancellation Charges : Basic fare +Airline administration fee 500 + Service Charges 250 Per Passenger Per Sector . |</Rule>
<adultCommission>0</adultCommission>
<childCommission>0</childCommission>
<commissionOnTCharge>0</commissionOnTCharge>
</BookingClassFare>
<Discount>0</Discount>
<airportTaxChild>0</airportTaxChild>
<airportTaxInfant>0</airportTaxInfant>
<adultTaxBreakup>2800,147,1320</adultTaxBreakup>
<childTaxBreakup>0,0,0</childTaxBreakup>
<infantTaxBreakup>0,0,0</infantTaxBreakup>
<octax>0</octax>
</FlightSegment>
</FlightSegments>
<id>arzoo11</id>
<key>wtZcSVMY/gphWFSOTFWg8oKRnosq3p9wt7R4SjMB0EUK8sDjVS91GicTJzH+TWN+pNURIyTJYKOW O8yH8+0tzpA4t8aEEvzaOE6ZnTtBotFDwLtSiN0xXqMsaDl8diV51l7d9ata/3rxTgfh9d8ZSmFY VI5MVaDywdHNcjAR1vwnEycx/k1jftlsnmWWqYGnJxMnMf5NY36YIq2FtLkfcHtsd+IDEhxpxJuT v4YyS+QnEycx/k1jftlsnmWWqYGnJxMnMf5NY37ZbJ5llqmBpycTJzH+TWN+GlZsae+KA6L3dlms eLkXZFKXPvd5FAnBXnTfRGc5sz+UC8CsZNzDV2FYVI5MVaDyFiThuG7WKPhzqWDbQb1E1IqUKT5I FtF6OaCYjb6EFGhDwLtSiN0xXt7N3OmPGVH2v18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506 L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506L2K/Xw4WWEWg j4D+4B+dOi9iv18OFlhFoI/87KPqwdBsCm4nF4DlZwRNQ/zni8QE42g8S0GV1z3SJXaOdoTFisn9 v18OFlhFoI+ThOYsjNAbXEP854vEBONoPEtBldc90iVD/OeLxATjaAwTg0ygCEBmEgnKEhG4Md1D /OeLxATjaDxLQZXXPdIlQ/zni8QE42jXGTnbB/ydvR4daAuN34kWYVhUjkxVoPJtRWbi6bZrXL9f DhZYRaCPgP7gH506L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI8KriAmVoEyR3OpYNtBvUTUp1Mf I240+obPusGaAOeuxg==</key>
</OriginDestinationOption>
</OriginDestinationOptions>
</Response__Depart>
</arzoo__response>
Now i have to display them as :
Base Price: 4850
Tax: 31
STax: 31
SCharge: 0
TDiscount: 0
TPartnerCommission: 0
.....................
Arrival Airport Code: DEL
.....................
I tried several methods using foreach():
$result = $client->__call('getAvailability',array($test));
$xml = simplexml_load_string($result);
foreach($xml->OriginDestinationOption as $od){
foreach($od->FareDetails as $fd){
foreach($fd->ChargeableFares as $cf){
echo $cf->ActualBaseFare;
}
}
}
but never sot it out. Can any one please help me out on this ?
Your help must appreciated. Thanks in advance
You are trying to access OriginDestinationOption as though it is a direct child of the XML response, but the structure is actually like this:
<arzoo__response>
<Response__Depart>
<OriginDestinationOptions>
<OriginDestinationOption>
So, since your $xml will represent the arzoo__response element, you need to traverse the other elements in between:
foreach($xml->Response__Depart->OriginDestinationOptions->OriginDestinationOption as $od)

Categories