Substring Question...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TARCON
Forum Newbie
Posts: 12
Joined: Wed Dec 02, 2009 3:34 pm

Substring Question...

Post by TARCON »

I have this image in my database: http://thumbs.forrent.com/imgs/fr/prope ... 000020.jpg

And in my database I have this URL for the image.

Well, where the PHP comes in, to show the image I am taking the subtring of the image of the first 25 characters.

My code is: $subImage = substr($image,0,25) where $image is the URL given...

I want to be getting: "http://thumbs.forrent.com"

But I am getting just a number 1.

Any help would be great...
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Substring Question...

Post by AbraCadaver »

Dunno why you're getting 1. echo $image and make sure it's what you think it is. Also, check out parse_url().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
TARCON
Forum Newbie
Posts: 12
Joined: Wed Dec 02, 2009 3:34 pm

Re: Substring Question...

Post by TARCON »

I got it now. It was doing it right in the first place.

When I printed the subImage in a if-statement, it would return 1. If I printed the subImage outside of the statement, it would return the desired result.
Post Reply