Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Please can anyone help me out, I've done an API Call and I need to get a single value from the response, as response comes with jsonp.
jsonp ({"statuscode":"025","RRR":"290007816182","status":"Payment Reference generated"})"
You should get response in a variable and use json_decode function like following :
$response = '{"statuscode":"025","RRR":"290007816182","status":"Payment Reference generated"}';
$result = json_decode($response);
echo $result->statuscode;
echo "<br>";
echo $result->RRR;
echo "<br>";
echo $result->status;
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
So, I get this assoc array structure :
pastebin.com/9nEGKsK0
How can I fetch the urls by 'foreach'?
Help.
You can try this:
<?php foreach($array['response']['items'] as $item) {
foreach($item['sizes'] as $size) {
echo $size['url'];
}
}
echo '<pre>';
print_r($array);
echo '</pre>';
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to pass some variables through url in php. Im using the following script
$query1 = new ParseQuery("Drivers");
$query1->includeKey("driverUserId");
$query1->descending("createdAt");
$results1 = $query1->find();
$object1 = $results1[$i];
$uname=$object1->get('driverUserId');
echo ''.$uname->get('name').'';
echo '<td>'.$uname->get('name').'</td>';
echo '<td>'.$uname->get('username').'</td>';
But when I execute the page, script stopped working in this line.
echo ''.$uname->get('name').'';
When I removed '.$uname.' it worked fine.
Because if $uname has a ->get() method, it's obviously a class or an object and you can't directly use it like a string (if it hasn't any tostring modifiers). Try to write it like this (just guessing):
echo ''.$uname->get('name').'';
Use the below code:
$id=$uname->get('id');
$name=$uname->get('name');
echo ''.$name.'';
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm retrieving the postal code by using -
<?php $pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/'); ?>
It works great but if the postal code is not found, it says, "None". I can't find a way to disable the message.
You can empty the variable if the respond is None. With a simple check.
<?php
$pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/');
if($pstcde === "None")
$pstcde = ""; //Empty string. Or you can use unset($pstcde); if you want to unset the variable.
?>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to make a code who echo a users name and his avatar from steam, but i dont know how, i tryied this: http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=52A66B13219F645834149F1A1180770A&steamids=76561197960435530 but i dont know how to get just the username and the avatar from that info im getting, any help?
You must get the content of this file through file_get_contents and parse that json format to php array. After just get element personaname and avatar and use it with your HTML code
An example of how you could parse that json.
$json = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=52A66B13219F645834149F1A1180770A&steamids=76561197960435530');
$parsed = json_decode($json);
foreach($parsed->response->players as $player){
echo $player->personaname . '<br>';
echo "<img src='" . $player->avatar . "'>";
}
If you have any questions, feel free to ask!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Im newbie in php im learning it since some weeks ago but i didnt understand one thing.
I have a
$url = "http://example.com/";
define('LOCATION', '<?php echo $url; ?>');
but it is not working. I didnt understand why "define" term cannot read
<?php
$url = "http://example.com/";
define('LOCATION', $url);
1.You are alreay in php tag,so no need of any extra php tag.
2.And when assigning value to a variable , we never use echo in php . Its used to display value in html only.