PHP Tutorials

PHP strpos() Function with Examples 0

PHP strpos() Function with Examples

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php // $mystr=”Data flair Free php course with free notes with Free certificate FREE code”; // //$n=strpos($mystr,”free”,13); // // $n=strrpos($mystr,”free”); // //$n=stripos($mystr,”free”); // $n=strripos($mystr,”free”);...

PHP strncasecmp() Function with Examples 0

PHP strncasecmp() Function with Examples

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php $s1=”flair”; $s2=”data”; echo similar_text($s1,$s2); // $s1=”data flair free course”; // $s2=”Data base system”; // //if(strncmp($s1,$s2,6)==0) // if(strncasecmp($s1,$s2,4)==0) // echo “<font color=green size=5>Same</font>”; //...

PHP string strcmp() Function 0

PHP string strcmp() Function

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php $mystr=array(“pune”,”indore”,”agra”,”bhopal”,”delhi”); print_r($mystr); for($i=0;$i<5;$i++) { for($j=$i+1;$j<5;$j++) { $n=strcmp($mystr[$i],$mystr[$j]); if($n>0) { $temp=$mystr[$i]; $mystr[$i]=$mystr[$j]; $mystr[$j]=$temp; } } } echo “—————————————–“; print_r($mystr); // $s1=”delhi”; // $s2=”dewas”; //...

PHP String Programs with Examples 0

PHP String Programs with Examples

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php $email=”[email protected]”; $m=substr_count($email,”@”); $f=0; if($m==1) { for($i=0;$i<strlen($email);$i++) { if($email[$i]==’@’) { $f=$i; break; } } $n=substr_count($email,”.”,$f+1); if($n==1) echo “<font color=green size=5>Valid email id</font>”; else echo...

PHP Case Related Function 0

PHP Case Related Function

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php $mystr=”vivek uprit data 123 flair”; $mystr=ucwords($mystr); //$mystr=ucfirst($mystr); // $mystr=lcfirst($mystr); echo $mystr.”<br>”; //$mystr=”DATA FLAIR FREE COURSE”; //$newstr=strtolower($mystr); // $newstr=strtoupper($mystr); // echo $mystr.”<br>”; // echo...

PHP chunk_split() and str_split() Function 0

PHP chunk_split() and str_split() Function

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php $mystr=”Data flair free course”; // $newstr=chunk_split($mystr,2,’.’); // echo $newstr; //$newarray=str_split($mystr,4); //print_r($newarray); //str_split() //chunk_split() ?> </pre> </center> </body> </html>  

PHP substr_count() Function 0

PHP substr_count() Function

Program 1 <html> <head><title>String in PHP Application</title> <body> <pre> <center> <?php //$email=”[email protected]”; $mystr=”Data flair free course of java script every course is free in Data flair”; // $n=substr_count($mystr,”free”,21); // echo $n; // $n=substr_count($mystr,”free”); //...

PHP explode() and implode() Function 0

PHP explode() and implode() Function

Program 1 <html> <head><title>Array in PHP Application</title> <body> <pre> <center> <?php // $s=”Data flair free course of php”; // $newarray=explode(‘ ‘,$s,3); // print_r($newarray) $myarray=array(“Data”,”Flair”,”free”,”course”,”with”,”free”,”certificate”); print_r($myarray); $mystr=implode(”,$myarray); echo “<br>”; echo $mystr; ?> </pre> </center> </body>...

PHP array_diff() Function 0

PHP array_diff() Function

Program 1 <html> <body> <center> <pre> <?php // $array1=array(“Mon”,”Tue”,”Wed”,”Sat”,”Mon”,”Sat”); // $array2=array(“Mon”,”Wed”,”Thus”,”Fri”); // print_r($array3); // $array3=array_diff($array2,$array1); // print_r($array3); $array1=array(“x”=>”Mon”,”y”=>”Tue”,”z”=>”Wed”,”k”=>”Sat”); // $array2=array(“x”=>”Mon”,”r”=>”Wed”,”t”=>”Thus”,”k”=>”Fri”); //$array3=array_diff($array1,$array2); //$array3=array_diff_key($array1,$array2); // $array3=array_diff_assoc($array1,$array2); // print_r($array3); ?> </pre> </center> </body> </html>  

PHP array_unique() Function 0

PHP array_unique() Function

Program 1 <html> <body> <center> <pre> <?php // $array1=array(“BTech”,”MCA”,”BTech”,”MTech”,”MCA”,”BCA”); // $newarray=array_unique($array1); // print_r($newarray); $array1=array(“x”=>”BTech”,”y”=>”MCA”,”z”=>”MTech”,”k”=>”BCA”); $newarray=array_keys($array1); echo “Key Array<br>”; print_r($newarray); $newarray1=array_values($array1); echo “Value Array<br>”; print_r($newarray1); ?> </pre> </center> </body> </html>