0

i want a simple php code that will get data from user e.g( https :// fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c0.0.180.180/s160x160/1525356_685076001544625_985694702_a.jpg) i want just this code from user from above example (1525356_685076001544625_985694702_a.jpg) when he will put all code into my website then my website will show him his/her large image.

-Note:i just want selective part(1525356_685076001544625_985694702_a.jpg) from user and show whole result like this - https : // fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/1525356_685076001544625_985694702_n.jpg

any help will be greatly appreciated...

12
  • Seems to work fine. I just tested with a profile picture. If you can edit your code into the question, or open another question, I am sure you will get help!
    – Dave Chen
    Jan 14, 2014 at 23:24
  • no man you are really nice please can u make php code whole as it is for me?? bcz i'm newbie sorry action=done.php please make complete done.php for me? plz? Jan 14, 2014 at 23:28
  • I'm unsure what done.php is for. You already show the fullscreen picture on profil.php, what else is there to do?
    – Dave Chen
    Jan 14, 2014 at 23:31
  • here it is mine link which is being created by me: itxjanu.tk/pic Jan 14, 2014 at 23:32
  • You have to change form action to http://itxjanu.tk/pic/done.php.
    – Dave Chen
    Jan 14, 2014 at 23:42

2 Answers 2

0

Try this:

<?php

$input = 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c0.0.180.180/s160x160/1525356_685076001544625_985694702_a.jpg';

$code = explode('/', $input);
$code = $code[sizeof($code)-1];

$code = substr($code, 0, -5);

echo 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/' . $code . 'n.jpg';

Output:

https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/1525356_685076001544625_985694702_n.jpg
3
  • thank u so much for helping me i'm gonna test it can u tell me one more thing? that is i need $input = (user's data not selective link you have just posted above) have a look please on this: profileviewer.comoj.com Jan 14, 2014 at 22:56
  • The name for the input is resimbaglanti. Try $input = $_POST['resimbaglanti'];.
    – Dave Chen
    Jan 14, 2014 at 22:57
  • let me try plz hold on thnks :) Jan 14, 2014 at 22:59
0

In addition to @Dave Chen anwser (shorter).

 $input = 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c0.0.180.180/s160x160/1525356_685076001544625_985694702_a.jpg';  

 $code = explode('/', $input);
 $code = substr(end($code), 0, -4);

 // or   version < PHP 5.4 
 $code = substr(end(explode('/', $input)), 0, -4);


 echo 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/' . $code . 'n.jpg';
10
  • shorter code is looking nice :) Jan 14, 2014 at 23:07
  • Please take a look at this question. Depending on your PHP version or on what errors/warning you may have enabled, this may be an issue. php.net/end
    – Dave Chen
    Jan 14, 2014 at 23:10
  • @DaveChen did you see that site i gave u above? Jan 14, 2014 at 23:17
  • @Dave Chen thanks! I forgot
    – voodoo417
    Jan 14, 2014 at 23:18
  • Of course. It looks amazing, good job on it!
    – Dave Chen
    Jan 14, 2014 at 23:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.