0

I have a url that ends with _s.jpg. The URL is set to a variable, and it called later on. Before it's called I need to slice the URL and remove _s.jpg and add _o.jpg.

$img_src = $data['picture'];

This returns my url

http://photos-b.ak.fbcdn.net/hphotos-ak-snc7/416968_4827318927507_851357969_s.jpg

I need the $img_src URL changed and then put into a new variable $new_img_src

I know I can do it with jQuery, but I need it done in PHP.

Thanks

2

1 Answer 1

3
$new_img_src = str_replace('_s.jpg', '_o.jpg', $data['picture']);

this ought to work...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.