fork download
  1. <?php
  2.  
  3. function makeLink($link) {
  4. if (stripos($link, "amazon.in") > 0) {
  5. if (strpos($link, "?") > 0) {
  6. $tmp = $link."&affiliate_id";
  7. } else {
  8. $tmp = $link."?affiliate_id";
  9. }
  10.  
  11. return $tmp;
  12. }
  13. }
  14.  
  15. "%s\n%s\n%s\n",
  16. makeLink('http://w...content-available-to-author-only...n.in/foo/b/ref=bar?ie=UTF8&node=baz'),
  17. makeLink('http://w...content-available-to-author-only...n.in/foo/b/ref=bar?node=baz'),
  18. makeLink('http://w...content-available-to-author-only...n.in/foo/b/ref=bar')
  19. );
  20.  
  21. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
http://w...content-available-to-author-only...n.in/foo/b/ref=bar?ie=UTF8&node=baz&affiliate_id
http://w...content-available-to-author-only...n.in/foo/b/ref=bar?node=baz&affiliate_id
http://w...content-available-to-author-only...n.in/foo/b/ref=bar?affiliate_id