Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to convert Unix time stamp into date time using PHP

Hello Reader's! If you have the time stamp in unix time and you need to convert them into Date time format Then you can use the diffrent ways of doing this in PHP Let's say the example below:- $timestamp=1455070324; echo gmdate("Y-m-d\TH...

How to get the vedio views from youtube using API in PHP

Hello Reader's If you want o get the total counts of a views on youtube video by api, then you can use the following php code. <?php $video_ID = 'your-video-ID'; //set the id from url $JSON = file_get_contents("https://gdata.youtube.com/f...

How to remove duplicate key values in a Multidimensional array using PHP

Hello Reader's If you have an multidimensional array which you want to sort. Then PHP offers you many ways to do it. Let's see the easiest way to achieve it:- Array ( [0] => Array ( [0] => dave [1] => jones...

How to convert string into an array using PHP

Hello Reader's! If you're having a problem to convert a string into an array then you can use the html entity in php. Let's see the example below:- & then be sure to use html_entity_decode // Input string // $input = 'pg_id=2_parent_...

Best way to send array with URL using PHP

Hello Reader's! If you want to send an array as a Param with the url then you can use the serialize and deserialize option from PHP Lets see the example below:- <?php $array["a"] = "Thusitha"; $array["b"] = "Sumanadasa"; $array["c"] = "L...

PHP date_add() Function ?

The date_add() function is mainly used for adding some days, months, years, hours, minutes, and seconds to a date. Syntax of date_add() date_add(object,interval); you can take belloe example for better understanding: <?php //her...

How to use strtotime() Function in PHP ?

The strtotime() function parses an English textual datetime into a Unix timestamps (the number of seconds since January 1 1970 00:00:00 GMT). Syntax of strtotime() Function strtotime(time,now); you can see belloe example: <?ph...

How to send a mail using php ?

In this blog we will see how to send a "Simple Text Email" ? The Php mail( ) function is used to send Emails in PHP. There are three main parameters we have to pass for sending a simple email and one is optional parameter. There 3 param...

How to use date() Function in php ?

The date() function formats a local date and time, and returns the formatted date string. Basically uses of The date() function formats a local date and time. The date() function returns the formatted date string. syntex of date () funct...

How to check image extension before uploading a image ?

There are many way to check image extension before uploading. But "in_array()" function it is very useful way to check image extension when you are uploading a lots of extensions to validate. if the "in_array()" function fails, this mean c...

How to ignore HTML content with tags using PHP

Hello Reader's If you want to make an function which truncate all the html contents and ignore them then you can uset the Sren Lvborg printTruncated function making it UTF-8 (Needs mbstring) function. It's example as below:- /* Truncate HTML, ...

How to send email using AJAX request?

Hello Reader's If you need to make ajax request that send the email in backgournd page then you can use the code below:- $('#submit').click(function() //specify your selector of form { $.ajax({ url: sendemail.php, // your action...

What is shuffle in PHP

Hello Reader's, If you want to know about shuffle function in PHP then this article is helpful for you. Lets say you want to generate 100 numbers on a random basis, a good way would be to generate an array with the numbers in order, then shuffle...

How to give output an image using PHP

Hello Reader's if you want to give output as an image then you can use the code below:- You can use finfo (PHP 5.3+) to get the right MIME type. $filePath = 'yourfile.ext'; $finfo = finfo_open(FILEINFO_MIME_TYPE); $contentType = finfo_fil...

How to use fgets in PHP

Hello Reader's If you need to read a given file line by line then PHP will offer you to use Fgets to do. Lets see it's example as below:- $handle = fopen("yourfile.txt", "r"); if ($handle) { while (($line = fgets($handle)) !== false) ...

Difference between array_key_exits and isset in array

Hello Reader we almost have header about array_key_exits and isset but you need to know the diffrence between them. Lets take an example below:- array_key_exists will only work when your key have an element and doesnt matter it is null, but is...

How to send an email using Gmail SMTP with PHP

Hello Reader's! If you want send an email with secure SMTP with you should choose google gmail smpt. And the code liberary is here:- $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMT...

Truncate a given sting just after a fixed count of chars using PHP

Hello Reader's! if you want to short a given string on fixed number of chars then php offers you many ways. Below is one of them, you can use this code for the same. Lets see the example below:- $sting_given = "1234567890134667896abcdtiABCD...

How you can stop the re submit of form using Unique id of form

Hello Reader's!, If you need a nice method to stop the form from again and again submit via refresh, PHP offers you many ways like header redriect or unset the $_POST but a pretty way is to implement a unique ID into the post and cache it in the...

How to unzip a file uisng PHP

Hello Reader's!, If you have a zip file and you need to execute unzip the file using PHP, Then you can use the PHP liberary code below:- // Lets say you have zip file in the same folder of php file. $file = 'file.zip'; // get the absolute ...

How to convert a given XML into PHP array

Hello Reader's!, If you are developing the website that takes input in XML and you want it to convert in PHP, Then you have to use some of the library extensions to do so. Let suppose you have the XML as given below:- <tag1Version="1.0"&...

How to send and email without SMTP using PHP

Hello Reader's! If you are new to php and need to send emails then PHP offers you many ways. But you can use the PHP code below, It's simple and does not use yourSMTP. Create a PHP page sentemail.php <?php if(isset($_POST['s...

How to Work With mkdir() function in PHP ?

The mkdir() function is basically use for making a directory. Syntax of mkdir() function mkdir("dir_name"); You can see below example of mkdir() function. <?php // here call mkdir() mkdir("testdocs"); ?> In the above ...

What is rand() function in php?

The rand() function is used to generate a random integer number. How to use rand() function? Syntax of rand() function:rand(); or rand(min,max); min:- min is use for Specifieing the lowest number that is retuned. Default min is 0. max:-m...

How to use $_Get in php?

PHP $_GET can also be used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL. You can see below example of $_Get in php. <!DOCTYPE html> <html> <body> ...

How to upload a file in php ?

When you want to upload your curriculum vitae, Your Profile picture, on the server then you can use File uploading method in PHP. With php concept you can easily upload your resume and any other document. There are tow important propert...

How to calculate number of days between two given date's in PHP

Hello Reader's! If you need to calculate the number of hours or days between two given dates then PHP offers you a lot of ways. But you can perform this task by the following way: Lets see the example below:- //Calculate number of hours betw...

How to get the colomn name of table using MySql

Hello Reader's, If you have to get the only names of columns of table then see the code below:- You can use following query for MYSQL:- SHOW columns FROM your-table; Below is the example code which shows How to implement above syntax in ph...

How to check if uploading file is in .csv extension using PHP

Hello Reader!, If you are looking for verify the uploading file with the correct extension with .csv only. Then you use the PHP code as below:- $allowed = array('csv'); //you can mentions all the allowed file format you need to accept, like ...

Object Iteration?

In PHP we can iterate any object by using the list of items,for getting list of items we have foreach loop in php. So that there will only the visible properties is being listed. We have loops concept for iterating throughout data list in php....

How to use $_POST in php.?

$_POST is basically used to accumulate form data after submitting an HTML form . $_POST is submit data with method="post". $_POST is also widely used to pass variables. You can see below example of $_POST. <!DOCTYPE html> <html&...

What is difference between session_unset() and session_destroy() in PHP -

The functioning part both the syntax will work the same but by inditing session_unset will clears the $_SESSION variable but will not ravage the variables and it will initialize to this stage: session_unset(); effaces only the variables from s...

How to configure Database in CakePHP

CakePHP database configuration details are in a file that is located at app/Config/database.php. the database file. You can edit the file in the notepad or sublime and can edit the feilds by which it will be connected to the database. Here w...

How do I get a YouTube video thumbnail from the YouTube API?

Hello Readers! We can use YouTube Data API to retrieve video thumbnails, caption, description, rating, statistics and more. API version 3 requires a key*. Obtain the key and create a videos: list request. Example PHP Code $data = file_ge...

How to remove duplicate values from a multi-dimensional array in PHP?

The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed. Example : <?php $a=array("a"=>"red","b"=>"green","c"=&...

How to use ucfirst() function in php ?

What is use of ucfirst() in php ? The ucfirst() function is used for converting the first character of a string to uppercase. Syntax of ucfirst() function: ucfirst(string) string is a parameter that is compulsory to given for convert...

What is superglobals Variables in php. ?

There are many predefined variables in PHP which are "superglobals", that denotes they are always accessible, regardless of scope. and you can access them according to your need from any function. So, there are 5 main superglobal variables i...

How to use of strtoupper() function in php.?

What is use of strtoupper() in php ? The strtoupper() function is used for converting a string to uppercase. Syntax of strtoupper() function:strtoupper(string) string is a compulsory parameter You can see below example of ucfirst() ...

How to use session in php. ?

Firstly let us know what is session ? Session variables hold information about one single user, and provide to all pages information in one application. So, session basicallu store informatiom in a variable and provine in multiple page for a ...

Redirection through htaccess file

.htaccess is the most useful file when we are working with php and apache. The directory level configuration of Apache server software is provided via .htaccess (Hypertext access) files. htaccess files defines mostly all the things like server se...

How to use of join() function in php.?

What is use of join() function.? The join() function returns a string from the elements of an array. The join() function alias of implode() function. Syntax of strtolower() function: join(" ",array) You can see below example of join()...

URL rewriting with PHP using .htaccess

Hello Readers! If you have this URL like : url.com/picture.php?id=51 and you want to make like this : picture.php/Some-text-goes-here/51 . In this case it can be done by using htaccess. Add a file called .htaccess in your root folder...

How to use of strtolower() function in php.?

What is use of strtolower() in php ? The strtolower() function is used for converting a string to lowercase. Syntax of strtolower() function:strtolower(string) string is a compulsory parameter You can see below example of ucfirst() f...

Send email using the GMail SMTP server from a PHP page

Hello Readers! You people can use below code if you are using Gmail SMTP connection. $from = '<fromaddres@gmail.com>'; $to = '<toaddress@yahoo.com>'; $subject = 'Hi!'; $body = "Hi, How are you?"; $headers = array( 'Fr...

What is use of ucwords() function in php.?

Definition of ucwords() function This function is used for converting the first character of each word in a string to uppercase. Syntax of ucwords() function:ucwords(string) string is compulsory paramere You can see below example of...

How to expire a PHP session after 30 minutes?

Setting the session creation time (or an expiry time) when it is registered, and then checking that on each page load could handle that. Example: $_SESSION['example'] = array('foo' => 'bar', 'registered' => time()); if ((time() - $...

How to parse and process HTML in PHP?

Hello Readers! If you want to parse any HTML page then you would you "Simple HTML DOM Parser". How to get HTML elements: Create DOM from URL or file $html = file_get_html('http://www.example.com/'); Find all images foreach($ht...

How to fix Headers already sent error in PHP

Hello Readers! You all got this error many times before and I am sure all PHP programmer at-least once got this error. To solve this error you can solve use solution as per your problem level: Possible Solution 1: You may have left blank...

How to use filter_var() function in php.?

What is use of filter_var() function. ? The filter_var() function filters a variable with the specified filter. Syntax of filter_var() functionfilter_var(var, filtername, options) You can see below example of array_rand() function in php...

How to use array_rand() function php.?

What does array_rand() function in php.? The array_rand() function returns a random key from an array, or it returns an array of random keys if you specify that the function should return more than one key. Syntax of array_rand() function:a...
1 8 14
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: