Browsing articles tagged with

web development

Php array of iso 639-1 language codes and names

Here is a php array containing the language codes and language names as specified by the iso 639-1 standard. Useful when . <?php /** ISO 639-1 Language Codes Useful in Locale analysis References : 1. http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 2. http://blog.xoundboy.com/?p=235 */ $language_codes = array( 'en' => 'English' , 'aa' => 'Afar' , 'ab' => 'Abkhazian' , 'af' => 'Afrikaans' , 'am' => 'Amharic' , 'ar' => 'Arabic' , 'as' => 'Assamese' , ...

Convert pdf to image with imagemagick in php

Imagick In a previous article we saw how to use to create a snapshot or thumbnail of the pdf. Now we are going to do the same in php using the Imagick class which provides the bindings for imagemagick library inside php. The library is available in the form of a class Imagick that does all the job of imagemagick ...

Php curl tutorial – making http requests in php

Curl According to the official website. curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, ...

6 tips to learn PHP fast and effectively

Php is today the most widely used language/platform for development of web based applications and websites. At the same time it is the easiest to learn and use. There are lots of free tutorial websites out there that can be followed to learn php without much effort. Along with these tools having the right approach can speed up the learning ...

Send html emails in php using the mail function

The mail function of php can be used to send not only plain text emails, but html emails too. The documentation page shows how to do that. Here is a easy to use function that does the task and has a form very similar to the mail function. function html_mail($to, $subject, $message, $options) { if(isset($options)) { $headers = "From: " . $options . "<".$options.">" . "rn"; } $headers ...

Fill text templates using arrays in php

Text templates are often used to generate content like notification emails, invoices filled with the details of a customer or user. The best example would be a bulk email program that sends out emails to multiple users filling the details of the particular user in every individual mail. Text templates have place holders for fields which can be filled using an ...

Php tutorial – Parse html DOM with DOMDocument

Domdocument The domdocument class of Php is a very handy one that can be used for a number of tasks like parsing xml, html and creating xml. It is documented here. In this tutorial we are going to see how to use this class to parse html content. The need to parse html happens when are you are for example writing scrapers, ...

Php : Get links on a page with DomDocument

Scraper scripts often need to extract all links on a given page. This can be done in a number of ways like regex, domdocument etc. Here is simple code snippet to do this using domdocument. /* Function to get all links on a certain url using the DomDocument */ function get_links($link) { //return array $ret = array(); /*** a new dom object ***/ $dom = new domDocument; /*** get the HTML ...

Php function to get the number of twitter followers

The following code snippet will fetch the number of twitter followers of a given twitter username /* This function will fetch the number of twitter followers of a twitter id It works by fetching an xml page for the user's information */ function get_followers($twitter_id) { $xml = file_get_contents('http://twitter.com/users/show.xml?screen_name='.$twitter_id); $s = simplexml_load_string($xml); $follower_count = $s->followers_count; return $follower_count; } /* Enter your twitter id here to test the code */ $twitter_id = 'linux'; echo "$twitter_id has ". get_followers($twitter_id) ...

Php function to add st, nd, rd, th to the end of numbers

Often numbers are to be written with a proper suffix, like 1st, 2nd, 3rd, 15th, 21st and so on. So here is a quick function to do the same for a number. Technique 1 /* This function will add st, nd, rd, th to the end of numbers */ function ordinal($i) { $l = substr($i,-1); $s = substr($i,-2,-1); return (($l==1&&$s==1)||($l==2&&$s==1)||($l==3&&$s==1)||$l>3||$l==0?'th':($l==3?'rd':($l==2?'nd':'st'))); } /* Example usage */ for($i = 0; $i < 100; $i++) { echo $i . ordinal($i). ...

Pages:123»


Connect with us