join() function php to array - php

I need to put xml into array and then use join function to show xml file
I extract already xml but don't know how to use join function for this code.
Please help me to figure out this.
Here is xml code:
<ValCurs Date="06.07.2012" name="Ratele oficiale de schimb">
<Valute ID="47">
<NumCode>978</NumCode>
<CharCode>EUR</CharCode>
<Nominal>1</Nominal>
<Name>Euro</Name>
<Value>15.3051</Value>
</Valute>
<Valute ID="44">
<NumCode>840</NumCode>
<CharCode>USD</CharCode>
<Nominal>1</Nominal>
<Name>Dolar S.U.A.</Name>
<Value>12.2343</Value>
Function to extraxt xml :
function curs() {
$date = date("d.m.Y");
$link = 'http://bnm.md/md/official_exchange_rates?get_xml=1&date='.$date;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml_array = curl_exec($ch);
curl_close($ch);
$xml_array = file_get_contents($link);
$values = array();
$curs = new SimpleXMLElement($xml_array);
foreach($curs as $key => $value) {
if (($value->CharCode) == 'USD') {
$values .= $value->Name." - ".$value->Value.", ";
}
if (($value->CharCode) == 'EUR') {
$values .= $value->Name." - ".$value->Value.", ";
}
}
$value = str_replace(',', '.', $values);
return $value;
}

It is not overly clear what you are asking for, but if I gather it correctly you want to do something like this. Note you were mixing array and string logic for the variable $values.
$values = array();
$curs = new SimpleXMLElement($xml_array);
foreach($curs as $key => $value) {
if (($value->CharCode) == 'USD') {
$values[] = $value->Name." - ".$value->Value;
}
if (($value->CharCode) == 'EUR') {
$values[] = $value->Name." - ".$value->Value;
}
}
$value = implode('.', $values);
return $value;
Note: I'm not sure on the usefulness of merging these strings with "." i'd expect you'd be after something like \n.

Related

Foreach loop inside while loop - it never ends

So, I have one curl API call which works fine when I do foreach outside the while loop. Once I move the foreach inside (because I need the values inside) it becomes an infinity loop.
This is the setup
$query = "SELECT id, vote FROM `administrators` WHERE type = 'approved'";
$result = $DB->query($query);
$offset = 0;
$length = 5000;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
do {
curl_setopt($ch, CURLOPT_URL, "https://api.gov/data?api_key=xxxxxxxxxx&start=1960&sort[0][direction]=desc&offset=$offset&length=$length");
$jsonData = curl_exec($ch);
$response = json_decode($jsonData);
foreach($response->response->data as $finalData){
$allData[] = $finalData;
}
$offset += count($response->response->data);
} while ( count($response->response->data) > 0 );
curl_close($ch);
while($row = $DB->fetch_object($result)) {
foreach ( $allData as $key => $finalData1 ) {
// rest of the code
}
}
Once I run the page it goes infinity or until my browser crash. If I move foreach ( $allData as $key => $finalData1 ) { } outside the while(){} there is no such problem.
Any ideas on what can be the problem here?
UPDATE: // rest of the code
$dataValue = str_replace(array("--","(s)","NA"),"NULL",$finalData1->value);
if($frequency == "dayly") {
if($dataValue) {
$query = "UPDATE table SET $data_field = $dataValue WHERE year = $finalData1->period AND id = $row->id LIMIT 1";
}
}
if(isset($query))
$DB->query($query);
unset($query);
One of the issues could be that where
// rest of the code
is, you have duplicate variable names, thus overriding current positions in arrays and loops.
However, you should change your approach to something like
$rows = Array();
while($row = $DB->fetch_object($result)) $rows[] = $row;
foreach ($rows as $row) {
foreach ($allData as $key => $finalData1) {
// rest of the code
}
}
That way you can read resultset from database faster and free it before you continue.

how to pass a value from repository to the controller in laravel

SmartpaySPaymentRepository.php
i am new to laravel. i want to passe this value ($url->nodeValue) which is in the SmartpaySPaymentRepository.php sendPaymentToSmartpaySForPaymentToken function to SmartPaySController.php getQuotePayment($quoteId) function can someone help me to do this?
public function sendPaymentToSmartpaySForPaymentToken($xml, $authToken, $transactionId, $doPrepareUrl)
{
$fields = array(
'authToken' => $authToken,
'&requestXML' => $xml,
);
$fields_string = $xml;
foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');
//open connection
$ch = curl_init($doPrepareUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
$response_from_smartpays = curl_exec($ch);
curl_close($ch);
$testString = $response_from_smartpays;//xml string
$dom = new \DOMDocument();
$dom->formatOutput = TRUE;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXml($testString);
$result = ($dom->getElementsByTagName('redirectURL'));
foreach ($result as $url){
return ($url->nodeValue);//want to passe this value to controller
}
}
SmartPaySController.php
public function getQuotePayment($quoteId)
{
$quote = $this->quoteRepo->getQuoteById($quoteId);
if($quote) {
$totalPrice = $quote->total_price;
if ($quote->amended_policy) {
$totalPrice = $quote->amend_price;
}
dd($url->nodeValue);//want to use $url->nodeValue here
$currency = CURRENCY_TYPE;
return $this->processSmartpaySPayment(PAYMENT_TYPE_QUOTE, $totalPrice, $currency, $quote->customer_id, $quoteId);
}else {
abort(404);
}
}
You can return them as an array in repository
$resultReturn = []
foreach ($result as $url){
$resultReturn[] = ($url->nodeValue);//want to passe this value to controller
}
return $resultReturn; // pass the array contiling all rsults in the loop
In the controller
$currency = CURRENCY_TYPE;
$results = $this->processSmartpaySPayment(PAYMENT_TYPE_QUOTE, $totalPrice, $currency, $quote->customer_id, $quoteId);
dd($results); //array of $url->nodeValue here
return $results;

php issues returning an array from a function

I'm pulling information through curl from Fedex Rate Quote Sytem. I am getting the necessary information. The curl functions correctly. The results are accurate. But, when I try to add the results to an array, it wont pass them from the function to the page. Its like the results arent being stored in the function.
foreach($result->SOAPENVBody->RateReply->RateReplyDetails as $value) {
$number = ++$number;
$key1 = $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType;
$value1 = $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;
$options[$key1] = $value1;
}
return $options;
I know that the function WILL pass the array set up like this as I tested it with
$key1 = '1';
$value1 = 'Hello';
It passed that information to the page.
When I echo out the curl results through $key1 and $value1 (echo $key1 . $value1;) it displays the correct information on the page as well. IT just wont pass it through to the array.
Below I am pasting the results from the echo to show what information is being retrieved
FIRST_OVERNIGHT: 194.35
PRIORITY_OVERNIGHT: 147.83
STANDARD_OVERNIGHT: 133.77
FEDEX_2_DAY_AM: 111.54
FEDEX_2_DAY: 99.78
FEDEX_EXPRESS_SAVER: 89.71
FEDEX_GROUND: 20.92
And I'm figuring someone will want to see how I am calling the function...here it is from the main page where the function is being called.
include_once('inc/functions/fedex_rate.php');
$fedex_options = array();
$fedex_options = fedex_rate($totalweight);
foreach ($fedex_options as $key => $value) {
echo '<tr><td colspan="2"><div class="margin10">'. $key .'</div></td><td colspan="2"><div class="margin10">'. $value .'</div></td></tr>';
}
I even tried just using $options as well in the foreach loop on the main page; however, that didnt work either. I finally saw an example where someone set up a new array using array details from the function and so that is where I stopped.
Below is the fedex rate quote complete function minus sensitive information
<?
function getProperty($var) {
if ($var == 'key') return 'xxxxxxxxx';
if ($var == 'password') return 'xxxxxxxxx';
if ($var == 'account') return 'xxxxxx';
if ($var == 'meter') return 'xxxxx';
}
function fedex_rate($totalweight) {
//your account details here
$key = getProperty('key');
$password = getProperty('password');;
$account_number = getProperty('account');
$meter_number = getProperty('meter');
$residential = '1'; // 1 = true, 0 = false
if ($residential == 1) { $residential = 'true'; }
if ($residential == 0) { $residential = 'false'; }
if($residential == 1) { $servicetype = 'GROUND_HOME_DELIVERY'; }
if ($residential == 0) { $servicetype = ''; }
$recipient_address = 'xxxxxxx';
$recipient_city = 'xxxxxx';
$recipient_state = 'xx';
$recipient_zip = 'xxxxx';
$recipient_county = 'xx';
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v13"><SOAP-ENV:Body><ns1:RateRequest>
<ns1:WebAuthenticationDetail>
<ns1:UserCredential>
<ns1:Key>'.$key.'</ns1:Key>
<ns1:Password>'.$password.'</ns1:Password>
</ns1:UserCredential></ns1:WebAuthenticationDetail>
<ns1:ClientDetail>
<ns1:AccountNumber>'.$account_number.'</ns1:AccountNumber>
<ns1:MeterNumber>'.$meter_number.'</ns1:MeterNumber>
</ns1:ClientDetail>
<ns1:TransactionDetail><ns1:CustomerTransactionId> *** Rate Request v13 using PHP ***</ns1:CustomerTransactionId></ns1:TransactionDetail><ns1:Version><ns1:ServiceId>crs</ns1:ServiceId><ns1:Major>13</ns1:Major><ns1:Intermediate>0</ns1:Intermediate><ns1:Minor>0</ns1:Minor></ns1:Version><ns1:ReturnTransitAndCommit>true</ns1:ReturnTransitAndCommit>
<ns1:RequestedShipment>
<ns1:DropoffType>REGULAR_PICKUP</ns1:DropoffType>';
// add- if service type is selected, echo service type code. if not, leave it out
//<ns1:ServiceType>'. $service_type .'</ns1:ServiceType>
$xml .= '<ns1:PackagingType>YOUR_PACKAGING</ns1:PackagingType>
<ns1:TotalInsuredValue>
<ns1:Currency>USD</ns1:Currency>
</ns1:TotalInsuredValue>
<ns1:Shipper>
<ns1:Contact>
<ns1:PersonName>Sender Name</ns1:PersonName>
<ns1:CompanyName>Sender Company Name</ns1:CompanyName>
<ns1:PhoneNumber></ns1:PhoneNumber>
</ns1:Contact>
<ns1:Address>
<ns1:StreetLines></ns1:StreetLines>
<ns1:City></ns1:City>
<ns1:StateOrProvinceCode></ns1:StateOrProvinceCode>
<ns1:PostalCode>xxxxxx</ns1:PostalCode>
<ns1:CountryCode>xx</ns1:CountryCode>
</ns1:Address>
</ns1:Shipper>
<ns1:Recipient>
<ns1:Contact>
<ns1:PersonName>Recipient Name</ns1:PersonName>
<ns1:CompanyName>Company Name</ns1:CompanyName>
<ns1:PhoneNumber></ns1:PhoneNumber>
</ns1:Contact>
<ns1:Address>
<ns1:StreetLines>'. $recipient_address .'</ns1:StreetLines>
<ns1:City>'. $recipient_city .'</ns1:City>
<ns1:StateOrProvinceCode>'. $recipient_state .'</ns1:StateOrProvinceCode>
<ns1:PostalCode>'. $recipient_zip .'</ns1:PostalCode>
<ns1:CountryCode>'. $recipient_county .'</ns1:CountryCode>
<ns1:Residential>'. $residential .'</ns1:Residential>
</ns1:Address>
</ns1:Recipient>
<ns1:ShippingChargesPayment>
<ns1:PaymentType>SENDER</ns1:PaymentType>
<ns1:Payor>
<ns1:ResponsibleParty>
<ns1:AccountNumber>'.$account_number.'</ns1:AccountNumber>
</ns1:ResponsibleParty>
</ns1:Payor>
</ns1:ShippingChargesPayment>
<ns1:RateRequestTypes>ACCOUNT</ns1:RateRequestTypes>
<ns1:PackageCount>1</ns1:PackageCount>
<ns1:RequestedPackageLineItems>
<ns1:SequenceNumber>1</ns1:SequenceNumber>
<ns1:GroupPackageCount>1</ns1:GroupPackageCount>
<ns1:Weight>
<ns1:Units>LB</ns1:Units>
<ns1:Value>'.$totalweight.'</ns1:Value>
</ns1:Weight>
<ns1:Dimensions>
<ns1:Length>10</ns1:Length>
<ns1:Width>10</ns1:Width>
<ns1:Height>10</ns1:Height>
<ns1:Units>IN</ns1:Units>
</ns1:Dimensions>
</ns1:RequestedPackageLineItems>
</ns1:RequestedShipment>
</ns1:RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
// remove colons and dashes to simplify the xml
$result_xml = str_replace(array(':','-'), '', $result_xml);
$result = #simplexml_load_string($result_xml);
;
$number = -1;
foreach($result->SOAPENVBody->RateReply->RateReplyDetails as $value) {
$number = ++$number;
$key1 = $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType;
$value1 = $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;
//echo $key1 .': '. $value1 .'<br />';
$options[$key1] = $value1;
}
return $options;
} // function
I was able to get it to work by adding an empty value before and after the $result in the array...but WHY is this the case? Why cant I pass the value of the $result tag to the array by itself?
$key1 = ''. $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType .'';
$value1 = ''. $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount .'';
CAN ANYONE TELL ME WHY I cannot pass the $result directly to the array without any additional blank tags? This ended up being the problem, so the person who figures that out gets the accepted answer.
After parsing XML, every element is SimpleXMLElement object and object can't be set as key in array.
When you concat empty string, it became string instead of Object. as you know when you try to echo an object it call __toString method (if defined).
if you like to debug this issue, try to call,
var_dump($result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType)
You can also resolve this by:
$key1 = (string)$result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType;
OR
$key1 = $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType->__toString();
The problem is that $options is not defined before in fedex_rate(). just define it as an empty array before the foreach.
$options = array();
foreach($result->SOAPENVBody->RateReply->RateReplyDetails as $value) {
....
I was able to get it to work by adding an empty value before and after the $result in the array...but WHY is this the case? Why cant I pass the value of the $result tag to the array by itself?
$key1 = ''. $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->ServiceType .'';
$value1 = ''. $result->SOAPENVBody->RateReply->RateReplyDetails[$number]->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount .'';

Invalid Signature while Connecting to Instapaper's Xauth on PHP

I've been trying to get a PHP application to connect to Instapaper's Xauth services, but for the life of me I can't get it to work. I keep getting an "403: Invalid signature." error.
The error says that my signature base string wasn't what it expected, but when I compare the signature base string I construct with what they say they expect, they're exactly the same (sensitive information removed):
My signature base string:
POST&https%3A%2F%2Fwww.instapaper.com%2Fapi%2F1%2Foauth%2Faccess_token&oauth_callback%3DMy_URL%26oauth_consumer_key%3DCONSUMER_KEY%26oauth_nonce%3Dfe379af261aca07d890d2cfaa0f19ce0%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1461898452%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth%26x_auth_password%3DPASSWORD%26x_auth_username%3DEXAMPLE%2540gmail.com
What the error says it expects:
POST&https%3A%2F%2Fwww.instapaper.com%2Fapi%2F1%2Foauth%2Faccess_token&oauth_callback%3DMy_URL%26oauth_consumer_key%3DCONSUMER_KEY%26oauth_nonce%3Dfe379af261aca07d890d2cfaa0f19ce0%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1461898452%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth%26x_auth_password%3DPASSWORD%26x_auth_username%3DEXAMPLE%2540gmail.com
I pulled my php library from https://github.com/mheap/Instapaper-XAuth-PHP, but it's old so I've tried to modify it to work with the current Instapaper API. I believe I'm generating the signature string correctly and am following the instructions found here: https://dev.twitter.com/oauth/overview/creating-signatures and here: http://oauthbible.com/
I don't know what's wrong with the code, can someone please help?
class XAuth_Connection
{
private $_headers = array(
"oauth_signature_method" => "HMAC-SHA1",
"oauth_version" => "1.0",
"oauth_callback" => "MY_URL",
"oauth_consumer_key" => "",
"oauth_nonce" => "",
"oauth_timestamp" => ""
);
private $_params = array(
"x_auth_mode" => "client_auth",
"x_auth_username" => "",
"x_auth_password" => ""
);
private $_access_url = '';
public function __construct($key, $private, $access_url)
{
$this->_headers['oauth_consumer_key'] = $key;
$this->_headers['oauth_nonce'] = md5(uniqid(rand(), true));
$this->_headers['oauth_timestamp'] = time();
$this->_oauth_consumer_private = $private;
$this->_access_url = $access_url;
}
public function set_credentials($user, $password)
{
$this->_params['x_auth_username'] = $user;
$this->_params['x_auth_password'] = $password;
}
public function get_params_as_string()
{
ksort($this->_params);
$req = array();
foreach ($this->_params as $k => $v)
{
$req[] = $k ."=". $this->encode($v);
}
return implode("&", $req);
}
public function get_headers_as_string()
{
ksort($this->_headers);
$req = array();
foreach ($this->_headers as $k => $v)
{
$req[] = $k . "=" . $this->encode($v);
}
return implode("&", $req);
}
public function generate_signature()
{
//combine the parameters, encode, and sort them
$temp_params = array_merge($this->_params, $this->_headers);
$encoded_params = Array();
foreach($temp_params as $k => $v){
$encoded_params[$this->encode($k)] = $this->encode($v);
}
ksort($encoded_params);
//Build the param string
$param_base_string = "";
foreach($encoded_params as $k => $v){
$param_base_string .= $k .'='. $v . '&';
}
$param_base_string = rtrim($param_base_string, '&');
//create the signature base
$signature_base = 'POST&' . $this->encode($this->_access_url) .'&'. $this->encode($param_base_string);
$key = $this->encode($this->_oauth_consumer_private) . '&';
return base64_encode(hash_hmac("sha1",$signature_base, $key, true));
}
public function login()
{
$this->_headers['oauth_signature'] = $this->generate_signature();
ksort($this->_headers);
$header_str = 'OAuth ';
foreach ($this->_headers as $k => $v)
{
$header_str .= $k.'="'.$this->encode($v).'", ';
}
$header_str = rtrim($header_str, ', ');
$oauth_str = $this->get_params_as_string();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_access_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $oauth_str);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: " . $header_str));
$exec = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] != 200)
{
return false;
}
parse_str($exec, $r);
return $r;
}
private function encode($s)
{
return ($s === false ? $s : str_replace('%7E','~',rawurlencode($s)));
}
}

How can I get the data from JSON code with PHP?

i just want get the data from the json link with the id == 0
how i can make this !?
<?php
$claw = "https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/43216818/ranked?season=SEASON4&api_key=010ba2bc-2c40-4b98-873e-b1d148c9e379";
$z0r = file_get_contents($claw);
$gaza = json_decode($z0r, true);
foreach ($gaza['champions'] as $key => $value) {
if ($value['id'] == 0) {
$wins = $value['totalTripleKills'];
}
}
?>
my code doesn't show anything ..
can anyone help !?
Your not outputing anything, your just assigning $wins over and over, there could also be an issue with file_get_contents not working as expected with over https urls.
Its faster and easyier to use cURL, also after a quick test it seems,
$value['totalTripleKills'] should be $value['stats']['totalTripleKills']
<?php
$url = "https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/43216818/ranked?season=SEASON4&api_key=010ba2bc-2c40-4b98-873e-b1d148c9e379";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
if(empty($result)) {
echo 'Error fetching: '.htmlentities($url).' '.curl_error($curl);
}else{
$gaza = json_decode($result, true);
foreach ($gaza['champions'] as $key => $value) {
if ($value['id'] == 0) {
echo $value['stats']['totalTripleKills'].'<br>';
}
}
}
Also its a rather large response so you will want to look into caching the result for a while, but thats beyond the questions scope.
There is an error you forgot to enter first in the stats array, otherwise you cannot take totalTripleKills value, then output it.
$claw = "https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/43216818/ranked?season=SEASON4&api_key=010ba2bc-2c40-4b98-873e-b1d148c9e379";
$z0r = file_get_contents($claw);
$gaza = json_decode($z0r, true);
foreach ($gaza['champions'] as $key => $value) {
if ($value['id'] == 0) {
$wins = $value['stats']['totalTripleKills'];
}
}
echo $wins;
Before you parse a json a helpful method to understand json structure of your data is this website: http://jsonlint.com/.
your not outputting anything,
<?php
$claw = "https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/43216818/ranked?season=SEASON4&api_key=010ba2bc-2c40-4b98-873e-b1d148c9e379";
$z0r = file_get_contents($claw);
$gaza = json_decode($z0r, true);
foreach ($gaza['champions'] as $key => $value) {
if ($value['id'] == 0) {
$wins = $value['totalTripleKills'];
}
}
?>
try this
<?php
$claw = "https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/43216818/ranked?season=SEASON4&api_key=010ba2bc-2c40-4b98-873e-b1d148c9e379";
$z0r = file_get_contents($claw);
$gaza = json_decode($z0r, true);
echo "<pre>";
foreach ($gaza['champions'] as $key => $value) {
if ($value['id'] == 0) {
$wins = $value['totalTripleKills'];
var_export( $wins );
}
}
?>

Categories