Contenu connexe
Similaire à Storytelling By Numbers (20)
Plus de Michael King (17)
Storytelling By Numbers
- 50. // This is a comment
/* This is also a comment
on multiple lines*/
- 54. $f = ‘marketing’ . ’festival’;
// Sets the value of $f to “marketingfestival”
- 55. if ( condition )
{
do things
}
elseif( condition)
{
do other things
}
else{
do other things
}
- 56. $a = 50;
if($a ==49)
{
echo “a is 49”;
}
elseif($a == 52)
{
echo “a is 52”;
}
else{
echo “a is not a known number”;
}
- 57. while foreach
for (initial value of counter; loop ending condition; counter increment or decrement)
{
do things
}
- 58. $count = 40;
For ($x=1;$x<($count+1);$x++)
{
echo $x . “<Br/>”;
}
- 59. $count = 40;
For ($x=1;$x<$count;$x++)
{
for ($y=0;$y<10;$y++)
{
echo $x+$y . “<Br/>”;
}
}
- 60. $variable[0] = “this is first element of an array”;
$variable[1] = “this is second element of an array”;
- 61. $variable[“element”] = “this is first associative element of an array”;
$variable[“second”] = “this is second associative element of an array”;
- 66. <?php
include_once"restclient.php";
$api= new RestClient(array(
'base_url' => "http://urls.api.twitter.com/1/urls",
'format' => "json"
));
$response = $api->get("count", array("v" => "1.0", "url" =>"http://www.marketingfestival.cz"));
- 70. for($x=0;$x<$countOfCsvLines;$x++)
{
echo '<tr>';
$result = $api->get("count", array("v" => "1.0", "url" =>$csv[$x]['urls']));
echo '<td>'.$csv[$x]['urls'].'</td>';
if($result->info->http_code== 200)
{
$twitterResponse= $result->decode_response();
$socialShares[$x]['urls'] = $csv[$x]['urls'];
$socialShares[$x]['tweetCount'] = $twitterResponse->count;
}
else{
$socialShares[$x]['tweetCount'] = 'unknown';
}
echo '<td>'.$socialShares[$x]['tweetCount'].'</td>';
echo '</tr>';
}
echo '</Table>';
makeCSV($socialShares,"shares.csv");
echo '<a href="shares.csv">Shares.csv</a>';