Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
<?php
$response = file_get_contents("http://api.trakt.tv/shows/trending.json/5d7588c188eeea0074b8d2664d12fffc");
$result = json_decode($response, true);
echo $result['title'][0];
echo "<br>";
echo $result['network'][0];
echo "<br>";
echo $result['air_day'][0];
echo "<br><img style='width:200px;' src='";
echo $result['images'][0]['poster'];
echo "'>";
?>
Ain't working. I don't know why.
I use the the trakt.tv shows API.
Write
echo $result[0]['title'];
instead of
echo $result['title'][0];
Besides, PHP's echo function will print integers and strings, but will fail with array-alike structures. You could use var_dump or var_export instead. Thanks to them, you could scan the structure and you wouldn't ask this question ;)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working on a website in which I want to do inline styling inside php tags.
<?php
if($data['item']->hello_world!=null)
{
echo "policy:";
echo strtolower($data['item']->hello_world->name);
echo "<br>";
echo strtolower($data['item']->hello_world->description);
}
?><?php
if($data['item']->hello_world!=null)
{
echo "policy:";
echo strtolower($data['item']->hello_world->name);
echo "<br>";
echo "<br>";
echo strtolower($data['item']->hello_world->description);
}
?>
The data which I want to style coming from the php code is:
echo strtolower($data['item']->hello_world->name);
Problem Statement:
I am wondering what changes I should make in the php code so that I am able to do styling for the above mentioned line.
To inline style the element:
echo '<span style="color: red">' . strtolower($data['item']->hello_world->name) . '</span>';
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Let me start by saying that i'm sorry if this is a complete noob question.
while using phpStorm, I have an array of $teams and by invoking foreach loop I tried to put each of the array section into an HTML table
here is what I did so far
I am getting cannot use [] for reading, I can't find an answer how to do that properly, thx in advance.
<table>
<tr>
<th>Team</th>
<th>ID</th>
</tr>
<?php
include dirname(__FILE__) . "/stats.php";
global $teams;
foreach ($teams['data'] as $team) {
echo "<tr>" ;
echo "<td> $team['name']</td>" ;
echo "<td> $team ['id']</td> " ;
echo "</tr>";
}
?>
</table>
To get the string substitution working correct, you have to suround it with {} if it's something more complex than a simple var - especially array access.
echo "<td> {$team['name']}</td>";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
echo <a href = 'test.php'> "CategoryID: " . $row["CategoryID"]. " - Category Name: ".$row["CategoryName"]. </a> "<br>";
This is what i have an is not working properly.
This:
echo "<a href = 'test.php'>CategoryID: {$row['CategoryID']} - Category Name: {$row['CategoryName']}</a><br />";
I am using the { and } as they allow you to include an array in a string and ignore the concatenation which I find harder to read.
I find it funny that you can loop through a MySQL array but can't echo a simple string :P
Some links (teach a man to fish...):
W3Schools
PHP documentation
Codecademy
Tutorials Point
Try this:
<?php
$link = "";
$link = sprintf("<a href = 'test.php'>CategoryID: %d - Category Name: %s </a><br />", $row['CategoryID'], $row['CategoryName']);
echo $link;
?>
Assuming that $row['CategoryID'] is an integer and $row['CategoryName'] is a string.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I wanted to take the fields such as ResumeParsingStartDate, ResumeParsingExpiryDate, MaxLimitOfParsedResume, NumberOfParsedResume
How can i take those valuse in php
Here is the Eval Link
Here is the array that i have
Here is the updated code :
Note : As stackoverflow's editor allows only 30,000 char the character has 35,000 char, and i can't able to decrease it anyway
You can get the single records like this :
$url = 'http://recruitplushrxmlapidemo.onlineresumeparser.com/hrxml/149Anne%20Marie%20Powell.xml';
$sxml = simplexml_load_file($url);
echo 'ResumeParsingStartDate --> '.$sxml->ResumeAdditionalItems->ResumeAdditionalItem[1]->ResumeParsingStartDate;
echo "<br />";
echo 'ResumeParsingExpiryDate --> '.$sxml->ResumeAdditionalItems->ResumeAdditionalItem[1]->ResumeParsingExpiryDate;
echo "<br />";
echo 'NumberOfParsedResume --> '.$sxml->ResumeAdditionalItems->ResumeAdditionalItem[1]->NumberOfParsedResume;
echo "<br />";
echo 'MaxLimitOfParsedResume --> '.$sxml->ResumeAdditionalItems->ResumeAdditionalItem[1]->MaxLimitOfParsedResume;
echo "<br />";
Use loop for repetitive elements
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
if ((isset($_GET['Menu']) && $_GET['Menu'] == "1" && $_GET['Overview']==1)
{
echo '$_GET['Overview']'
}
if statement to receive parameter from the URL
Because you cannot use if the way you do. Split up the echo, then it should work:
echo "<li><a " ;
if($_GET['Menu']==1) { echo 'class="select"'; }
echo " href=javascript:setParam('Menu',1);>Networks</a></li>";
$x="";
if($_GET['Menu']==1)
$x= 'class="select"';
echo "<li><a>".$x." href=javascript:setParam('Menu',1);>Networks</a></li>";
Im partial to sprintf for concatenation, but thats just me:
echo sprintf('<li><a %s href=javascript:setParam(\'Menu\',1);>Networks</a></li>',
$_GET['Menu']==1 ? 'class="select"' : '');
You need to echo every part of your code:
echo "<li><a ";
if($_GET['Menu']==1) { echo 'class="select"'; }
echo " href=javascript:setParam('Menu',1);>Networks</a></li>";