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
How to Combine two arrays - one for key and another for value
Hello friends,
If you want to combine 2 arrays in which 1 is used as a key and another as value then you can use a predefined PHP function which is "array_combine". array_combine function creates an array by using one array for keys and anothe...
Slug in PHP
Hi All,
Slug :- It is a part of the URL to makes the URL more user-friendly. There are also many other advantages of the Slug. Firstly, search engines such as Google will rank your page higher for the keywords contained in the URL Secondly, us...
get a array of a column from a multidimensional array
Hello friends,
Here I am explaining that if you want to get all the values from a specific column from a multidimensional array then you can use a php predefined function which is "array_column()".
array_column returns the values from a sing...
How to use array_combine() in PHP.
Hello Readers ,
Suppose we have two array's .
$fname=array("Peter","Ben","Joe");
$age=array("35","37","43");
The array_combine() function creates an array by using the elements from one "keys" array and one "values" array.
Example ...
How to find the number of days until a particular date?
To find the number of days until a particular date you need to write the following PHP script:
<?php
$date1="December 31,2015";
$date2=strtotime($date1);
$date3=ceil(($date2-time())/60/60/24);
echo "There are " . $date3 ." days until $d...
How to splits an array into chunks of new arrays
Hello Readers ,
If we want to split one array into bunches of new arrays then their is a PHP function named "array_chunk()" that we can use.
The array_chunk() function splits an array into chunks of new arrays.
<!DOCTYPE html>
<...
how to change all keys in an array to lowercase.
Hello Readers ,
If we want to change the array key lower case to uppercase and vice versa then their is PHP function array_change_key_case() .
Example.
<!DOCTYPE html>
<html>
<body>
<?php
$age=array("Peter"=...
Split an array into given length of array
Hello friends,
Here I am explaining, if you want to split an array into given size element(length) of arrays then you can use array_chink() predefined function of php. array_chunk function chunks an array into arrays with size elements and may...
How to display the dates for the next six Saturdays?
In PHP, to display the dates for the next six saturdays you need to write the following script.
<?php
$startdate=strtotime("Saturday");
$enddate=strtotime("+6 weeks",$startdate);
while ($startdate < $enddate) {
echo date("M d",...
Change array keys in LOWER or UPPER case
Hello friends,
If you want to change the array keys in either upper case or lower case then you can use a predefined array function of PHP which is "array_change_key_case()". array_change_key_case returns an array with all keys from array lowe...
Replacing all instances in a string
You can replace all instance in a string using str_replace with the help of str_replace function.
In this example, str_replace replaces all instances of abc with xyz like this:
echo str_replace("abc","xyz","abcdefghijklmn");
the output w...
Predefined Filter Constants in PHP
There are many predefined Filter Constants in PHP which is passed as a second parameter value in the filter_var() function. Some of them are:
FILTER_VALIDATE_BOOLEAN: Used to validate a boolean.
FILTER_VALIDATE_EMAIL: It is used to validate...
Replace part of string at particular position
You can easily replace a part of string at a given postion of a substring with the help of string function known as substr_replace
$string2="abcdefghijklmnop";
if (strpos($string2,"abcd")!==false)
{
$pos=strpos("abcd",$string2);
$l...
Sanitize and Validate a URL
To sanitize and validate a URL a function filter_var() is used. It also removes all the illegal characters from the URL. It includes two parameters one is the variable that is needed to check and other is the type of the variable. If you want to...
filter_var() Function
In PHP, to validate and sanitize external input filters are used. filter_var() function is used which perform both validate and sanitize external input. It takes two parameter:
variable: It specify the variable you want to check.
type: It s...
How to send HTML email in PHP
In today's world of internet, Email become one of the most popular and demanded service. Email become a necessary part of web development, email can be generate and send on different events such as registration of new users, activation of account...
Custom Pagination With Bootstrap
Hi All,
I recently required to created a custom pagination with the help of Bootstrap in my core PHP project. I thought that my code may help others also who wish to create the same.
The reason why I am using Bootstrap is as it ease our wor...
How to find the number of words and number of characters in a string?
Find the number of words in a string:
In PHP, to find number of words in a string a function str_word_count() is used. It includes three parameters:
string: It a required parameter which specify the string to check.
return:It is an optiona...
How can we prevent SQL-injection in PHP?
Hello Readers ,
For preventing SQL injection we can do by two ways :
1- > Escaping the special characters in your post or get variables , or
2-> By using a parameterized query.
Both would protect you from SQL injection.
Ex...
Search For a Specific Text Within a String
In PHP, to search for a specific text within a string a function strpos() is used. It includes 3 parameters:
string: It is required parameter which specify the string to search.
find: It is also a required parameter which specify the string t...
How to use base64_encode() in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss How to use base64_encode() in PHP ?
If you want to convert any string into MIME base64 then base64_encode() function is very useful and simple process
let see syntax of bas...
How to upload restricted image in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss How to upload restrict file in PHP ?
If you want upload only jpg, gif image and other type of images not allow to upload
then, you have to use bellow php code:
<?php
...
What is process to make custom session timeout in php ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss What is process to make custom session timeout in php ?
If you want to make the custom php session which will destroy automatic when page is not refreshing so long time.
yo...
Replace all white spaces with a single space in PHP
Hello friends,
Today I am here to explain you that how to replace all white spaces with a single space in php with the help of pregamatch method. You can use following method.
$input = 'Hello firends. how are you.';
$outpu...
How to pass an arrray in PHP via Ajax
Hello Readers if you want to send the array into another PHP page then you can use the code below:-
I have array made by function .push. In array is very large data. How is the best way send this to PHP script?
dataString = array(a->b);...
How to add two objects into one using PHP
Hello Reader's if you want to add two or more objects into one. Then you can see it into the example below:-
Ideally if you want the data to be together, you should have a parent class which has all these member functions and you should have a...
How to convert string to binary and binary to string using PHP
Hello Readers if you want to convert your string into binary using PHP then you can use the code syntax as below:-
$value = unpack('H*', "This string is converting into binary");
echo base_convert($value[1], 16, 2);
Output:-
010100110...
How to superimpose one image over another using PHP
Hello Readers if you have two images i.e. one png and one jpg, Then by using PHP you can merge both on a single one.
Lets see the example as given below:-
<?php
# If you don't know the type of image you are using as your originals.
$...
How to implode multi-dimensional array keys using PHP v5.5
Hello Readers, If you want to implode the array keys from multi-dimensional array then now PHP 5.5 offers you much easier way to do this.
Lets see the example as below:-
Array
(
[0] => Array
(
[studenID] =>...
How to get Clean URL in Drupal 7
Hello Friends,
In Drupal generally URL setup like "http://www.abc.com/?=node/38". If you are looking to setup clean URL like "http://www.abc.com/node/38". Please follow the below steps for the same::
1) Open administrative panel
2) After...
Determine if string exists in input string
You can determine particular string exist in an input string with the help of strpos function. strpos returns false if the string is not found. It provides 0 if found at the beginning of string. It finds the position of occurrence of string wi...
How to replace a text with a string?
To replace a text with a string a function str_replace() is used. It replaces all the occurences of the string that you have searched with the string you want to give in that place.
For example:
<?php
$str = "String in which you replace ...
foreach() function in PHP
foreach() function provides an easy way to scan arrays & exactly do the same thing like for loop, so this function is said to be PHP foreach loop. foreach loop works only on arrays.
Syntax:
foreach ($arrayname as $value) {}
Example...
sort() & rsort() function in PHP
Sort() function is used to sort array in ascending order.
Example:
<?php
$numbers = array(9, 6, 3, 22, 12);
sort($numbers);
$length = count($numbers);
for($x = 0; $x < $length; $x++) {
echo $numbers[...
What is Zend Registry and how we can use this
Hello Friends,
Zend Registry is temporary global storage area. In zend registry you can save values, object or array. With the reason this is global you can access this storage data in any page, controller etc. This is some this similar to sav...
unlink() vs unset() Function
unlink() Function:
This function is used for file system handling.
It deletes the file used in context. For example:
unlink('demo.txt');
The above line will delete the file unlink completely.
It includes two parameters: filen...
Useful Extensions/Modules for Themers
Please find the below listing of some very useful module that will make the theme developer life easier
Sweaver Make themes editable by anyone
Chaos Tool Suit Provides a collection of APIs and tools to assist developers for example aj...
Joomla Menu manager
Menu manager contains list of all menu items of website and allows options such as add,edit,rebuild menus. First you need to login on Joomla administrator panel and navigate to Menus> Menu Manager from the menu across the top of the Joomla adm...
Joomla 3.0 favicon
You can easily change favicon in Joomla using the following steps.
First Create your Favicon with the dimensions 16x16 pixels, once you create it save it by using the name "favicon.ico". We can easily generate favicon using the free on...
How to get file name from full path with PHP?
To get the file name from full path in PHP function basename() is used. It contains two parameters one is path(the path to from which you rquired a filename) and suffix(it specify the file extension. If the filename has this extension then it dis...
basename() Function
The basename() function is used to extract the filename from a path. In other words, the function returns the filename from a path. It contains two parameters:
path(Required): it specify the path to check
suffix(Optional): It is a optional ...
Custom HTML module in joomla
We can create custom HTML module in joomla using the administrative area.
Go to Extensions -> Module Manager.Then click New icon and select Custom HTML as a module type.
A new page will open where user need to enter the title of th...
joomla insert,update and delete
WE can easily manipulate our data from database in Joomla by using the below code. First need to call jfactory::getDBO$db = &JFactory::getDBO(); returns a reference for the database object in joomla.
For INSERT query in Joomla structure
...
How to update an extension in Joomla?
To update an extensions in Joomla you need to follow the steps given below:
Login to the back-end of the Joomla i.e., Admin section
Now click Extensions-> Extension Manager
Extension Manager page will appear. Now click Update.
This pag...
How to use Order By in Zend Framework
Hello Friends,
If you are looking to use order by clause in Zend Framework. Please use the below code for the same::
$dbObj = Zend_Db_Table::getDefaultAdapter();
$selectObj = $this->select();
$selectObj->from(array('tbl_users'),arra...
Joomla 2.5 vs 3.0
1. Bootstrap: Joomla 3.0 is Bootstrap. With basic CSS already integrated into Joomla 3.0,while Joomla 2.5 is without bootstrap.
2. Less: LESS is a dynamic stylesheet language which has been integrated into Joomla 3.0. Template development has ...
pathinfo() Function
pathinfo() function basically contains the information of the file path. It will take two parameters:
path(required) : path whose information is needed.
options(optional) :tells which elements to return. Values are PATHINFO_DIRNAME(returns ...
Theming the views, Drupal 7
Views is the most popular module among the Drupal developer as it provides the visual query builder. views have lots of supportive module which enhance the functionality of views modules.
Some basic works you can do by using views
...
Authentication Check each time the Page reloads using laravel 4.x
In every project we have minimum 2 sections. First is User Section and second is Admin Section and In our routes we want to put authentication check each time when page is loaded.
I can easily explain this by using simple example.
Route::gr...
Error Messages of File Array
Whenever you upload a file using PHP script it will return a error code with file array. This code you will find in the error section of the file array i.e., $_FILES['filename']['error']. Code are as follows:
UPLOAD_ERR_OK: Value '0'
Th...