Featured
-
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Best 5 Lightweight PHP Frameworks for REST APIs Development
Are you ready to develop the Rest AP
by ankur.kumar -
PHP: Full-Stack Framework vs Micro Framework
A web framework can be described as a software fra
by ankit.bhatia -
How to get facebook profile picture by Facebook App
If you would like to get your profile picture in f
by vivek.rastogi -
Creating RESTful API in cakephp
This tutorial will help you to learn how to create
by pushpendra.rawat
Tags
Inserting array values at the beginning of an array in PHP
Hello Readers ,
With the use of array_unshift() , it will insert new values at the beginning of an array.
We can add one value, or as many as you like.
Syntax:
array_unshift(array,value1,value2,value3...)
Example:
<?php
$...
How to add custom setting in wordpress admin panel?
Hello readers, In this blog I will guide you "To add theme option in wordpress admin panel"
The below code create a page in your admin dashboard. In dashboard a new tab create Pinboard, when you open this tab you can see three link
Gener...
Removing duplicate values from an array in PHP
Hello Readers,
If we want to remove the duplicate values present in an array then their is a function named array_unique() that we can use .
If two or more array values are the same, the first appearance value will be kept and the other wil...
crypt() String Function in PHP
The crypt() function in PHP returns a hashed value. It uses the DES, Blowfish, or MD5 algorithms.
It returns the first two characters of the output as salt in DES-based crypt(). As salt parameter is optional but crypt() function gives a weak p...
Range of an array in PHP
With use of range() function , it creates the array contains the range of an element.
It will return an array of element from low to high.
Syntax :
range(low,high,step)
Example :
<?php
$number = range(0,50,10);
print_r ($num...
filemtime() Function
The filemtime() function is used to get the modification time of the file i.e., the time file was last modified.
Syntax:
filemtime($filename);
In above function there is only one parameter which is the name of the file you want to get th...
Currency exchange rate using Google Api
Google provides a simple and free* API for querying currency exchange rate. You can convert the currency using google apis url which are given below
https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency...
How to add custom attributes on product in WooCommerce?
Hello Everyone, In this blog I will guide you "To add custom attributes on product in WooCommerce?"
This is how to produce custom item attributes on the WooCommerce single web page. (To display attributes on the cart page, see Indicate WooComm...
How to use auto suggestion in textbox
Hello Friends,
In the current web world many websites are using auto suggest box instead of drop-down. If you want use this please follow the below example:
1) Define your text-box
<input name="abc" id="search-box" class="form-control...
How to change add to cart text on product page by its type?
Hello Everyone, today I will guide you "to change add to cart text on product page by its type?"
If you want to change the add to cart text according to product type, the first thing is you have to get the product type. In the below code $pro...
Create a random string of x characters using defined string of possible characters
To create a random string of x characters using defined string of possible characters we will first of all define a function which will return a random string of length that you have passed as a parameter to the function. The script is given belo...
How to compare two text strings in PHP
There are different methods to check two text strings are equal or not in PHP. This article defines the methods which can be used for comparing two text strings.
1. '==' : == operator is most commonly used operator for comparing two strings. I...
Set up cookies in PHP
We can set the cookies with function called setcookie() . This function requires six arguments to be pass.
Syntax:
setcookie(name, value, expire, path, domain, security);
Creating cookies:
<?php
setcookie("name", "John Watkin...
How to delete last element in an array
Hello Readers ,
If we have an array and we want to delete the last record in an array then their is a function called array_pop() .
The array_pop() function deletes the last element of an array.
Example :
<?php
$a=array("red","gre...
How to insert more values in an array in PHP
Hello Readers ,
If we want to insert more records at the end of an array then their is function called array_push() that we can use.
Example :
If we have an existing array array("red","green"); and we want to insert two more values at th...
How to find the particular value in an array in PHP
Hello Readers ,
Most of the time in our application we need this function called in_array .
This function searches an array for a specific value.
Example :
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (in_ar...
How to suffle an array in PHP
Hello Readers ,
If we have the certain array in php and we want to suffle the values of an array then we have the function called shuffle().
This function randomize the vales in an array.
Example :
<?php
$my_array = array("red","g...
Computes the intersection of arrays
If you want to get all those values which exist in an array and also exist in other array means intersect values between an array and the set of other arrays then you can use a predefined php function array_intersect. array_intersect() returns an...
Computes the intersection of arrays using keys for comparison
If you want to get an array which contain all the entries of an array and have keys that are present in some other arrays for this you can use a predefined function array_intersect_key ( array $array1 , array $array2 [, array $... ] ).
array_i...
Exchanges all keys with their associated values in an array
Hello friends,
This time I am here to explain a very common issue in php which if is someone want to exchange the array keys with values, for this you can use a predefined php array function "array_flip ( array $array )". array_flip ( $array )...
Fill an array with values
Hello friends,
If you want to to fill a specific value as an array value then you can use a predefined PHP function "array_fill ( int $start_index , int $num , mixed $value )". This function returns an array filled by given values.
In this $...
Fill an array with values with specifying keys
If you want to fill the values in array with specifying keys then you can use the pre-defined function "array_fill_keys()" means in this function you pass 2 array as parameter, the values of first array used as key of new array and second array u...
Reset password check for validation before login and redirecting
In Laravel 5.0 we have in built functionality for forgot password or resetting password. Once the user reset his/her password he/she is logged-in and redirected to the specific URL. But what if the user is deactivated by the super admin temporari...
Uploading an image using curl to remote location
When you are trying to upload a file . file get always uploaded using post. So you need to place @ before the file name which you want to send as a post. Using @before the file path in order to make sure that CURL sends the file in the form ...
Getting a Youtube video thumbnail using youtube Api
You can use YouTube video related information using YouTube API, using this API you can retrieve details such as video thumbnails, caption, description, statistics and more. You just need to obtain the YouTube key and create a videos: list reque...
Computes the difference of arrays using keys for comparison
Hello Friends,
If you want to compare two array with respect to keys not values then you can use a predefined PHP function "array_diff_key()". array_diff_key function compares the keys from array1 against the keys from array2 and returns the d...
How to set database configration in Codelgniter
Hello Guys,
If you are looking set database configuration in Codelgniter. Please follow the below step for the same::
1) Open the file application/config/database.php and complete the below information:
$db['default']['hostname'] = 'localh...
How to apply security patches in magento using php file
We need to upgrade our magento setup time to time with release of the editions because of security reasons. Sometime we need to apply the security patches also to resolve security issues. Here I am explaining how to apply securtiy patches without...
How to set conditions in Find function of cakephp2.x
In cakephp we might be familiar with the simple find("all") and findById() functions.
But fetching data with some conditions like we write select query with where condition.
lets us first look at simple find function
$this->User->f...
How to combining two strings together in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss combining two strings together in PHP.
The PHP concatenate(.) is used for combining two string values and create one string.
you can see bellow example:
<?php
/...
How to use array_slice() function in php ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss array_slice() in php ?
The array_slice() function is used to for returning selected parts of an array.
syntax of array_slice()
array_slice(array,start,length,preserve...
Display a random entry from a MySQL database in PHP
To display a random entry from a MySQL database we need to use a MySQL function rand(). To display the entry from MySQL database in PHP following script is used:
<?php
//connect to server with username and password,
$connection = mysql_co...
How to write custom mysql query in Wordpress
Hello Guys,
Some time we need to custom mysql query. If you are looking to write custom mysql query in Wordpress. Please follow the code for the same::
global $wpdb;
$sender_name = $wpdb->get_results("SELECT first_name,last_name FROM se...
sizeof() Function in PHP
In php the sizeof() Function returns the number of elements in an array.
Syntax
sizeof(array,mode);
The argument array specifies the array and the mode specifies whether to count multidimensional array or not
the value 0 specifies do...
How to get last key in an array in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to get last key in an array in PHP ?
we need in some cases the last key or last element of an array in PHP.
So We are using array_slice() function for getting only the ...
How to use key() finction in php ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss about key() function in php.
The key() function returns the index element of the current array position.
Or we can say that returns the element key from the current internal ...
How to use end() finction in php ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss about end() function.
The end() function is used for printing last element of an array.
It is advances array s internal pointer to the last element.
syntax of end() functio...
How to use redirect in Wordpress
Hello Friends,
While developing a website we need to redirect from one page to another. We use different type of redirection in different-different development languages and framework and CMS. If you are looking to use redirection in wordpress...
Decimal to Binary, Hexadecimal and Octal conversion
Decimal to Binary conversion
To convert decimal to binary conversion a function decbin() is used. Syntax:
decbin(number);
Example:
<?php
echo decbin("43") ;//specify the decimal that is need to convert
?>
Decimal to He...
How to update record in Wordpress
Hello Guys,
If you are looking to update data in wordpress database, please follow the below example::
global $wpdb;
$address_data['state'] = $_REQUEST['state'][$i];
$address_data['country'] = $_REQUEST['country'][$i];
$address_data['zip...
Degrees / Radians conversions in PHP
To convert degree to radians and radians to degree following function are used:
<?php
//degrees to radians function
function DegToRad($degrees)
{
return $degrees * 3.14 / 180;
}
//radians to degrees conversion
function RadToDe...
Display MySQL server information in PHP
To display MySQL server information in PHP a function mysql_get_server_info() is used. It returns version of MySQL server on success else false.
For example:
<php
//enter your hostname,username and password of mysql
mysql_connect("loca...
How to traverse a Multidimensional array in PHP?
Multidimensinal array is the array of arrays. You can store multidimensional array as follows:
$arr=array(
array(1,"demo1","demo2"),
array(1,"demo3","demo4"),
array(1,"demo5","demo6"),
array(1,"demo7","demo8")
);
To traverse a multid...
Computes the difference of two or more arrays with additional index check
If you want to compute the difference of two or more than 2 array with index means to compare 2 array with the index of arrays for this you can use the predefined PHP function "array_diff_assoc()".
array_diff_assoc() compares array1 against arra...
How to interchange values and keys of an array in PHP
Hello Readers ,
The array_flip() function exchanges all keys with their associated values in an array.
Say we have array array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); and we want to interchange key and values of an a...
array_fill_keys() in PHP
Hello Readers ,
The array_fill_keys() function fills an array with values, specifying keys.
For Example we have an array array("a","b","c","d"); and we want to put "blue" in all values of a key. See the below example.
<!DOCTYPE html&g...
Count the frequency of values in an array
Hello friends,
If you want to count all the values in an array means you want that how much time a value is exist in an array then you can use a predefined PHP function which is "array_count_values()". array_count_values() returns an array usi...
array_diff_assoc() in PHP
Hello Readers ,
Suppose we have two three array it will search with all three arrays and return an array that contains the values from array 1 that are not present in rest of the array
Example :
<?php
$a1=array("a"=>"red","b"=&g...
How to count the value of an array in PHP
Their is function called "array_count_values()" which will count all the values of an array.
Lets suppose we have an array **array("A","Cat","Dog","A","Dog");** and we want to count the values of an array.
Example :
<!DOCTYPE html>...
Compare strings in php
You will always get a situation where you want to compare the values with each other whether with the integers or with the string comparison.
We can easily compare two strings with the help of comparison operator.If the two strings are equal to...