bigtimslim Posted April 2, 2008 Share Posted April 2, 2008 I use the file_get_contents function to get the html from a page. I parse through that page and get a specific url I want. It looks similar to this: http://www.domain.com/index.cfm?action=blah&ID=5000 Now I want to file_get_contents the above url. I understand that the & is for html so I tried to convert the string to work as a url. I tryed both using urlencode function on the query of this url and just manually through php replacing with what I thought were the appropriate characters with no luck. Can anyone help, or point me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/99265-solved-file_get_contents-and-characters-in-a-url-problem/ Share on other sites More sharing options...
Caesar Posted April 2, 2008 Share Posted April 2, 2008 <?php $url = str_replace('&','&','http://www.domain.com/index.cfm?action=blah&ID=5000'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/99265-solved-file_get_contents-and-characters-in-a-url-problem/#findComment-507898 Share on other sites More sharing options...
discomatt Posted April 2, 2008 Share Posted April 2, 2008 You want to convert HTML special characters back to their originals http://php.net/manual/en/function.html-entity-decode.php Quote Link to comment https://forums.phpfreaks.com/topic/99265-solved-file_get_contents-and-characters-in-a-url-problem/#findComment-507902 Share on other sites More sharing options...
Caesar Posted April 2, 2008 Share Posted April 2, 2008 There's that. ;-) Quote Link to comment https://forums.phpfreaks.com/topic/99265-solved-file_get_contents-and-characters-in-a-url-problem/#findComment-507905 Share on other sites More sharing options...
bigtimslim Posted April 2, 2008 Author Share Posted April 2, 2008 Thanks very much guys for the quick replies. Caesar I thought tried that same exact thing last night... then I said what the heck and tried your code and of course it worked. I must have been doing something stupid. Thanks for the link discomatt that is exactly what I needed. Quote Link to comment https://forums.phpfreaks.com/topic/99265-solved-file_get_contents-and-characters-in-a-url-problem/#findComment-507917 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.