FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Trimmin Quotes.





Gushe
So, I wrote a script that gets an image source from an extern website like this:

Code:
"http://www.examplewebsite.com//p/oo/429/202/29202622.jpg"


But I don't seem to be able to display that image on my site.
I thought of trimming it first, like this:
(assuming $input is the image source)
Code:

$input = trim($input, "\"");


But that isn't working for me.. I searched on google but I couldn't find anything that eventually Worked to trim my string right or display the image on my webpage.

Any help on this one? Rolling Eyes


Thanx in Advance;
GuShe.
rvec
try this:
trim($image, "\x22");
Gushe
Nope.. Not working here. Confused
sonam
Is this your site from where you want get image? If is not, maybe is hotlink protection enabled. In that case you cannot get this image. This is not problem here on frihost.

Sonam
rvec
Code:
<?php
$image = '"http://www.examplewebsite.com//p/oo/429/202/29202622.jpg"';
echo trim($image, "\x22");
?>


That script gave me this output:
http://www.examplewebsite.com//p/oo/429/202/29202622.jpg

You sure you don't have any spaces or stuff added?
Gushe
No spaces or things added.

If I simply do
Code:
echo $image;
it prints:
"http://www.examplewebsite.com//p/oo/429/202/29202622.jpg"
Including the quotes.

I checked for hotlinking. I put some of the images in a HTML page which displayed correctly on my webserver here.

Here is my full script:
Code:
      for ($i=1; $i <= $amount; $i++)
         {
         $source = strstr($source, "img src=");
         $source = ltrim($source, "img src=");
         $pos = strpos($source, " ");
         $input[i] = substr($source, 0, $pos);
         echo trim($input[i], "\x22") . "<br>";

It's searching a webpages source for all images.
But it keeps on outputting them with quotes. Confused
Star Wars Fanatic
Try str_replace():

Code:
$input = str_replace ( '"' , "" , $input ) ;


It replaces " with nothing ("").
It will replace all occurrences of the double quotes.
Gushe
that didn't do it, But I found a working solution! Very Happy

Code:
$input[i] = trim($input[i], "&quot;");


Off course I retrieved them from a HTML page, so I had to trim the HTML values.

Thanx Anyway! Wink
Related topics
Great One-Liners & Quotes
Love And Friendship Quotes
Random Quotes Services for anyone - 1 Frih$ for 170+ quotes
Favorite Quotes
Do We get points for quotes?
[PHP] HTML entities, inputs, quotes
Pulling quotes from wikiquote
Anchorman quotes
Collection of the most memorable quotes by FriHost members:)
Favourite Dumbledore Quotes
Linux Quotes [:d]
Christianity: Why so many Churches? / Denominations?
seinfeld quotes - not that there's anything wrong with that
Anime Quotes, and Meanings
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.