String Function

Posted on Updated on

String Function

String : String is the power full method which Is use to write the line on the webpage . String is the collection of words which are provide some information . String is the data type and it dispale with the help of ( “ “ ) double quotes . we can store the string into a variable and show it where we want to display .

Syntax of declare a string :

     $string _ line = “ hello dear how are you and what are you doing . this is my testing of the string “ ;

After declare the string the question is to how to display the output .

String and Display it : –

<?php

$str _ s = “ hello dear how are you and this is my first program in string “ ;

Echo $str _ s;

?>

Output will be :

Hello Dear how are you and this is my first program in string.

There are many function of the string which are write below :

 Strlen ( )

 Str _ word _ count ( )

 Str _ rev ( )

 Strops ( )

 Str _ replace ( )

 Strlen ( ) : = strlen function is the function of the string which is use to find the length of the string it count the space as well as the letter of the string .

Syntax :

Strlen ( “ stirng here “ ) ;

For example :

<?php

$str _ len = “ hello dear how are you this is my string length function to find the length “ ;

Echo “ string length is = “ . strlen ( $str _ len ) ;

?>

It show the out put string length is = 75

 Str _ word _ count ( ) : = string word count is the string function which is use to count words in a string without count the spaces .

Syntax :

Str _ word _ count ( “ string word here “ ) ;

Example :

<?php

$strin _ w _ count = “ hello dear how are you this is my string word count function to find the count of words “ ;

Echo “ you write = “ . str _ word _ count ( $strin _ w _ count ) . “ words “ ;

?>

Output will be :

You are write = 18 words

 Strrev ( ) : = strrev function is the string function which is use to display the string in reverse order .

Syntax :

Strrev ( “ string pass here “ ) ;

Example :

<?php

$str _ rev = “ hello dear how are you this is my string reverse method which help to write or display in reverse order . “ ;

Echo “ reverse order of string is = “ . strrev ( $str _ rev ) ;

?>

Reverse order of string is = . redro esrever ni yalpsid ro etirw ot pleh hcihw dohtem esrever gnirts ym si siht uoy era woh raed olleh

 Strpos ( ) : = this function is use to check the position of the word in the which we want to find. it count from the letter .

Syntax :

Strops ( “ string here “ , “ value here “ ) ;

Example :

<?php

$position = Strpos ( “ hello dear this is my string and here I get the position of the word “ , “ my “ ) ;

Echo “ your word position is : “ . $position;

?>

Output :

Your word position is : 19

 Str _ replace : = this string function is use to replace the string .

Syntax :

Str _ replace ( “ which word we have to replace “ , “ with which word we have to replace “ , “ string here “ ) ;

Example :

<?php

Echo “ this is your replacement string : “ . Str _ replace ( “ hello “ , “ hi “ , “ hello dear this is my string

and here I replace the word “ ) ;

?>

Output will be

This is your replacement string : hi dear this is my string and here I replace the word

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s