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 8 years ago.
Improve this question
Hi i am trying to get video title from dailymotion videos.
$imgid = $video_cek["embed"]; //this is dailymotion id (ex. xint71)
$hash = unserialize(file_get_contents("http://www.dailymotion.com/services/oembed?
format=json&url=http://www.dailymotion.com/embed/video/$imgid"));
$video_cek['baslik']=$hash[0]['title'];
I cant find where is the problem.Thanks
The problem is you are returning JSON Format but trying to unserialize that, this should work:
$imgid = $video_cek["embed"];
$hash = json_decode(file_get_contents("http://www.dailymotion.com/services/oembed?format=json&url=http://www.dailymotion.com/embed/video/$imgid"), true);
$video_cek['baslik']= $hash['title'];
you get a json response, so use json_decode function to Takes a JSON encoded string and converts it into a PHP variable.
like:
$array = json_decode($hash, true);
echo $array['title'];
or
$array = json_decode($hash);
echo $array->title;
Related
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 8 years ago.
Improve this question
I wrote a program that uses an ISBN to query Amazon for that ISBN's price, and returns the following result:
5cb66919-8a8d-4c13-9175-790f0476508d0.0401580000000000TrueISBN9780340979266OffersAllAll0340979267809USD$8.09688USD$6.88598USD$5.98241010000
I need to format this so that I have the price information in a format that would be understandable to a human.
How can I do this?
Use this way..
<?php
$s = '5cb66919-8a8d-4c13-9175-790f0476508d0.0401580000000000TrueISBN9780340979266OffersAllAll0340979267809USD$8.09688USD$6.88598USD$5.982410100000';
$p = explode('USD',$s);
echo "<pre>";
print_r($p);
echo "</pre>";
?>
function returnPrice($response){
$prices = explode('USD',$response);
unset($prices[0]);
return $prices;
}
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 8 years ago.
Improve this question
I find out about Apple lookup API and wanted to try something.
JSON: http://itunes.apple.com/lookup?id=443904275
It's only read resultCount, I can't read other data for example app name:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$json = file_get_contents('http://itunes.apple.com/lookup?id=443904275');
$data = json_decode($json,true);
$appname = $data['artistName'];
echo "<pre>";
echo ($appname);
exit;
?>
You need to understand the structure of the object. What you need is:
$appname = $data['results'][0]['artistName'];
Looks like you need to use $data['results'][0]['artistName']
...assuming $data['resultCount'] == 1.
You can always put http://itunes.apple.com/lookup?id=443904275 in your browser to see exactly what you're PHP is working with.
(Edit: what Jonathan said...)
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 8 years ago.
Improve this question
I have tried to pass a variable trough url... its %50.
I am doing urlencoding to pass other languages through the url.
At that time %50 also been converted to a space or something else.
Can anyone help me to find out a way to send %50 as a variable through urlencoded link(url).
<?php
$string = '%50';
echo $encoded = urlencode($string);
// returns %2550
echo urldecode($encoded);
// returns %50
?>
So if you want to pass $string to a url you write something like:
http://yoursite.com/script.php?string=$encoded
To get your original string value you can just use $_GET in your script.php:
echo $_GET["string"];
// returns %50
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 8 years ago.
Improve this question
I have a host of files that generate link like this for hosted files:
http://endertec.com.br/hf/see-img.php?img=http://www.endertec.com.br/hf/do.php?imgf=Fav2.png
But when I see link like this on Facebook, it looks like this:
http://endertec.com.br/hf/see-img.php?img=http%3A%2F%2Fwww.endertec.com.br%2Fhf%2Fdo.php%3Fimgf%3Fav2.png
So I researched ways to convert it, and got the following code:
<?php
$str = 'http://www.endertec.com.br'.$_SERVER['REQUEST_URI'];
$src = str_replace('see-img.php?img=' , '' ,stristr($str , 'see-img.php?img='));
string rawurldecode ( string $src )
echo '<img src="'.$src.'"/>';
?>
But for some reason it does not work, does anyone know how it might work?
You need to store your rawurldecode in something.. try something like this:
$decoded_src = rawurldecode($src);
echo '<img src="'.$decoded_src.'" />';
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
I don't know exactly how to say this, I'll use an example.
//[$var:Username|n] will print username with n length
$myText = 'The participants are [$var:Username|10], [$var:Username|8], and [$var:Username|6]';
$username = array('Alexandrite', 'Maximillian', 'Angelina');
$result = someFunction('[$var:Username|n]', $username, $myText);
echo $result;
//The participants are Alexandrit, Maximill, and Angeli
Any idea how to do this? Maybe using preg_replace?
I'm interested to know why you would even need to do this. Regardless:
preg_replace_callback('/\[\$var:Username\|(\d+)\]/', function ($match)
use (&$count, $username
) {
return substr($username[$count++], 0, $match[1]);
}, $myText);