Home / Core PHP

Core PHP

How to get the common sub string in two string?

<?php function retriveCalc($str1,$str2){ $arr1=array(); for($i=0;strlen($str1)>$i;$i++){ $arr1[$i]=$str1[$i]; } $arr2=array(); for($i=0;strlen($str1)>$i;$i++){ $arr2[$i]=$str1[$i]; } $result = array_intersect($arr1,$arr2); return implode('',$result); } $str1='test'; $str2='testingindia'; echo retriveCalc($str1,$str2); echo "<br>"; $str1='1234'; $str2='4254546234231'; echo retriveCalc($str1,$str2); ?>

Read More »

PHP 5 Global Variables – Superglobals

Superglobals were introduced in PHP 4.1.0, and are built-in variables that are always available in all scopes. PHP Global Variables – Superglobals Several predefined variables in PHP are “superglobals”, which means that they are always accessible, regardless of scope – and you can access them from any function, class or …

Read More »

PHP 5 Sorting Arrays

The elements in an array can be sorted in alphabetical or numerical order, descending or ascending. PHP – Sort Functions For Arrays In this chapter, we will go through the following PHP array sort functions: sort() – sort arrays in ascending order rsort() – sort arrays in descending order asort() …

Read More »

PHP 5 Arrays

An array stores multiple values in one single variable: Example <?php $cars=array("Volvo","BMW","Toyota"); echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; ?> What is an Array? An array is a special variable, which can hold more than one value at …

Read More »

PHP 5 Functions

The real power of PHP comes from its functions; it has more than 1000 built-in functions. PHP User Defined Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in a program. A function will not …

Read More »

PHP 5 for Loops

PHP for loops execute a block of code a specified number of times. The PHP for Loop The for loop is used when you know in advance how many times the script should run. Syntax for (init counter; test counter; increment counter) { code to be executed; } Parameters: init …

Read More »

PHP 5 while Loops

PHP while loops execute a block of code while the specified condition is true. PHP Loops Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal code-lines in a script, we can use …

Read More »

PHP 5 switch Statement

The switch statement is used to perform different actions based on different conditions. The PHP switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be …

Read More »

PHP 5 if…else…elseif Statements

Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In PHP we have the following conditional statements: if …

Read More »

PHP 5 Operators

This chapter shows the different operators that can be used in PHP scripts. PHP Arithmetic Operators Operator Name Example Result + Addition $x + $y Sum of $x and $y – Subtraction $x – $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y …

Read More »
Welcome to VShakya

For this week my all price is very low !

Don't miss to get my services

Thanks

 

Contact us