Search Results
Article: Tidy Up A URL With PHP
… Lots of applications require a user to input a URL and lots of problems occur as a result. I was recently looking for something that would take a URL as an input and allow me to make sure that is was formatted … so I decided to write it myself. The following function takes in a URL as a string and tries to clean it up. It essentially does this by …
… to the function. The following example reads a web page using the PHP CURL functions and then passes the result into the function to retrieve the links. $url = 'http://www.hashbangcode.com'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); …
Article: Shortening Long URLs With PHP
… Print out a full URL for a link will sometimes mess up your formatting, especially if you URL is quite long. This might be the case if you are linking to a Google search page, or have an automated script that shows numerous URLs of indeterminate length. The following function will reduce any …
Article: Preparing A URL With PHP
… be many instances where you will create a program in PHP that takes a URL as input and does something with the address. This might be a site … an image resize, but whatever the use is, you need to be sure that the URL will work or at least has the same format. What users tend to leave out of a URL string is the http:// bit at the start. You could validate the URL …
… wrote about recently on the site. The function originally found any URL strings within a larger string and turned them into links. The … thing, except that the link text has been shortened using the shortenurl() function. $longurl = "there is the new site …
… = 0,$j = count($paragraphs);$i < $j;$i++) { // create links around URLs $paragraphs[$i] = preg_replace('/((ht|f)tp:\/\/[^\s&]+)/','<a …