CodeIgniter is one of the PHP MVC Framework with minimum learning curve best documentation and easy workflow, in CodeIgniter we can easily Enable or Disable GZIP Compression by Changing Config array values (TRUE – […]
How to Set, Get and Delete Cookies in CodeIgniter ?
We can Set, Get and Delete Cookies with CodeIgniter Cookie Helper, Cookie Helper contains functions that assist in working with cookies. Before using Cookie Helper functions you Should load cookie Helper, in the following […]
How to Refresh Current Page in CodeIgniter?
With the help of CodeIgniter Built in function redirect(), we can refresh or redirect the page based on given parameters. CI’s redirect() is resides in the URL helper, so in order to use redirect() function, you […]
Validate Multiple Phone numbers Comma Separated with PHP?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$str = "9703132428,123456789,1"; // convert string to array $numbers = explode(',', $str); // remove empty items from array $numbers = array_filter($numbers); // trim all the items in array $numbers =array_map('trim', $numbers); // default error count $error = 0; // array to store invalid numbers $inValidNumbers = array(); // loop through all the numbers in array foreach($numbers as $number) { // number validation we allow only 0 to 9 , min 5 max 14 number only if(!preg_match("/^[0-9,]{5,14}$/", $number)) { $error++; // increment error count // push the invalid numbers into array array_push($inValidNumbers,$number); } } if($error != 0) { 'invalid numbers : '. implode(", ", $inValidNumbers); } else { // do something... } |
php explode at capital letters?
You can explode a string at capital letters with preg_split function, see the below example
1 2 3 4 5 |
$string = 'HelloWorld'; // ?=[A-Z] = matches "A-Z", but does not advance the current position $array = preg_split('/(?=[A-Z])/', $string); $final_result = implode(' ', $array); echo $final_result; |
List of top tutorials on how to create an API With PHP?
List of top tutorials on how to create an API With PHP? Creating a RESTful API with PHP(2013) Creating an API-Centric Web Application(2011) Create a RESTful API in less than 5 minutes(2010) Create a REST API with PHP(2009) […]
How to get Alexa Rank with PHP ?
Alexa is one of the most well known and popular web information providers. It provides information about web site’s traffic stats, reviews, backlinks and many more. Here this post is about to get Alexa rank using […]
Create Bit.ly Short URLs Using PHP?
One of the more popular and powerful URL shortening services is Bit.ly. Bitly offers simple and powerful API to generate short URL. To use this API you have to signup for an API key. Bitly offers it free for it’s […]
How to downlaod Files using CodeIgniter?
CodeIgniter has a nice helper function to download files. It is a nice way to download from server without any hassle just writing one single controller method.
1 2 3 4 5 6 7 8 9 |
public function download ($file_path = "") { // load ci download helder $this->load->helper('download'); // get download file path and store it in $data array $data['download_file'] = $file_path; // load view file $this->load->view("download_view",$data); redirect(current_url(), "refresh"); } |
How to Increase file size upload limit using .htaccess ?
Most of the web Hosting providers give access to overriding the .htaccess, To Increase file size upload limit via .htaccess just copy the bellow settings into your .htacess file and put it in your web root directory
1 2 3 |
php_value upload_max_filesize 10M php_value post_max_size 20M php_value memory_limit 128M |