Most popular php string function in hindi

Most popular php string function in hindi

Introduction

हेलो दोस्तों आज हम इस post में php most popular string function के बारे में जानेगे!. PHP में string के साथ operation perform करने के लिए PHP में by default function available है!. string के साथ operation perform करना जैसे की string को replace करना, string length finds करना, string capitalization, main string से substring को find करना तो ऐसे सारे operation के php हमें by default function provide करता है तो आज हम खास ऐसे ही string function के बारेमे जानेगे!.

What is string?

PHP में string character का एक sequence (group) होता है और php में इसे हम तीन तरीके से define कर सकते है!.

– single quoted
– double quoted
– heredoc syntax

1. single quoted

single quoted में string को single quoted में declared किया जाता है!. (‘ ‘) single quoted character

Example: 

<?php
   $single_quoted = 'Hello this is single quoted strings';
?>

2.double quoted

double quoted में string को double quoted में declared किया जाता है!. (” “) double quoted character

<?php

  $double_quoted = "Hello this is double quoted strings";

?>

PHP ke most important string functions

  • strlen()
  • is_string()
  • strstr()
  • substr()
  • str_replace()
  • trim()
  • strpos()
  • strtolower()
  • strtoupper()
  • ucfirst()
  • ucwords()
  • icfirst()

1. strlen() function

php में strlen() function का इस्तेमाल string की length check करने के लिए होता है!.

Example:

<?php

 $str = "This is string length checking function";
 echo strlen( $str );

?>

2. is_string() function

php में is_string() function यह check करता है की variable का type string है या नहीं यह function true return करेगा अगर variable का type string हुवा तो यातो वह false return करेगा अगर variable का type string नहीं हुवा तो!.

Example:

<?php
 $str = "Hello";
 if( is_string( $str ) ){
   echo "This is string";	
 }else{
  echo "This is not a string";
 }
?>

3. strstr() function

php में strstr() function का इस्तेमाल string sequence में specific string word और character को find करने के लिए होता है!.
For example “This Is Hello Word” string है और उसमेसे “Hello” string find करनी है तो strstr() function के इस्तेमाल से करा सकते है!.

Example:

<?php
 $str ="This Is Hello Word";
 echo strstr( $str, "Hello" );
?>

4. substr() function

php में substr() function आपको string के लिए दिए गए starting और end points के बीच की substring access करने के लिए इस्तेमाल होता है!. इस function का इस्तेमाल string  के किसी specific points से string को access करनी की जरूरियात पड़ जाती है तब इस function का इस्तेमाल होता है!.

Example:

<?php
 $str =" Hello world ";
 echo substr($str,6);
?>

5. str_replace function

php में किसी string का word replace करना पड़ जाये तो str_replace function का इस्तेमाल किया जाता है!.

Example:

<?php
 $str = "Hello this is first string";
 $replc = str_replace("first","second",$str);
 echo replc;
?>

6. trim function

php में trim() function string के दोनों side से whitespace और predefind character को remove कर देता है string से!.
trim() के related function जैसे की।
1. ltrim() = string के left side से whitespace और predefined character को remove कर देता है string मेसे.
2. rtrim() = string के right side से whitespace और predefined character को remove कर देता है string मेसे.

Example:

<?php
 $str = "Hello world!";
 echo $str;
 echo "<br>";
 echo trim( $str,"llod!" );
?>

7. strpos() function

php में किसी main string मेसे substring को find करने के लिए strpos() function का इस्तेमाल होता है!. strpos() function substring की position return करता है!.

Example:

<?php
 $str = " Hello this is newstring ";
 echo "String Position Number is:".strpos($str, 'this');
?>

8. strtolower() function

php में string को uppercase to lowercase में convert करने के लिए strtolower() function का इस्तेमाल होता है!.

Example:

<?php
 $strlwr = " HELLO THIS IS STRING ";
 echo $strlwr;
 echo "<br>";
 echo "This is lower case string:".$strtolower($strlwr);
?>

9. strtoupper() function

php में किसी string को lowercase to uppercase में convert करने के लिए strtoupper() function का इस्तेमाल होता है!.

Example:

<?php
 $strupr = "Hello this is string";
 echo $strupr;
 echo "<br>";
 echo "This is uppercase string:".strtoupper($strupr);
?>

10. ucfirst() function

php में ucfirst() function string की first character को uppercase में convert करके return करता है!.

Example:

<?php
 $string = " This is my first string ";
 $sting = ucfirst( $string );
 echo $string;
?>

11. ucwords() function

php में ucwords() function string के सभी word के first character के uppercase में convert करके return करता है!.

Example:

<?php
 $string = "This is my first string";
 $string = ucwords( $string );
 echo  $string;
?>

12. lcfirst() function

php में lcfirst() function string के first character के lowercase में convert करके return करता है!.

Example:

<?php
 $string = " This Is My First String ";
 $string = lcfirst($string);
 echo  $string;
 
?>

 

Leave a Comment

Your email address will not be published. Required fields are marked *