आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
PHP - String

String में multiple characters होते है | PHP में String के लिए 70+ string functions है जिनका इस्तेमाल string पर operation करने के लिए किया जाता है |

PHP में कुछ ज्यादा इस्तेमाल होनेवाले String Functions

String FunctionDescription
strlen()String की length को return करता है |
strtolower()Uppercase string को Lowercase string में convert कर देता है |
strtoupper()Lowercase string को Uppercase string में convert कर देता है |
str_replace()String में से कुछ characters या substring को किसी दुसरे character या substring से replace किया जाता है |
strcmp()यहाँ पर दो strings को compare किया जाता है |
trim()शुरुआत में और आखिरी के substring या characters को trim किया जाता है |
ltrim()left-side मतलब शुरुआत के substring या characters को trim किया जाता है |
rtrim()right-side मतलब आखिरी के substring या characters को trim किया जाता है |
ucwords()words के हर पहले character को lowercase से uppercase में convert कर देता है |
lcfirst()string में से पहला character uppercase से lowercase में convert कर देता है |
ucfirst()string में से पहला character lowercase से uppercase में convert कर देता है |
strrev()string को reverse किया जाता है |
strip_tags()string में से html tags को rmove कर देता है |
chop()String के आखिरी characters को remove कर देता है |
htmlentities()string में से html code को html entites में convert कर देता है |

 

Example for strlen() String Function

Source Code :
<?php
$str = "Hello World!";
echo $str . "<br />";

$len = strlen($str);

echo "Length of String is ".$len;
?>
Output :
Hello World!
Length of String is 12

Example for strtolower() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$lower = strtolower($str);

echo "LowerCase String : ".$lower;
?>
Output :
Hello World!
LowerCase String : hello world!

Example for strtoupper() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$upper = strtoupper($str);

echo "UpperCase String : ".$upper;
?>
Output :
Hello World!
UpperCase String : HELLO WORLD!

Example for str_replace() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$replace = str_replace("World", "Friends", $str);

echo "Replaced String : ".$replace;
?>
Output :
Hello World!
Replaced String : Hello Friends!

Example for strcmp() String Function

<?php

$compare1 = strcmp("Hello World", "Hello World");
echo $compare1 . "<br />";

$compare2 = strcmp("Hello World", "hello World");
echo $compare2 . "<br />";

$compare3 = strcmp("hello World", "Hello World");
echo $compare3 . "<br />";

?>
Output :
0
-1
1

Example for trim() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$tr = trim($str, "Held!");
echo $tr;
?>
Output :
Hello World!
o Wor

Example for ltrim() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$ltr = ltrim($str, "Held!");
echo $ltr;
?>
Output :
Hello World!
o World!

Example for rtrim() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$rtr = rtrim($str, "Held!");
echo $rtr;
?>
Output :
Hello World!
Hello Wor

Example for ucwords() String Function

<?php
$str = "hello world!";
echo $str . "<br />";

$ucw = ucwords($str);
echo $ucw;
?>
Output :
hello world!
Hello World!

Example for lcfirst() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$lcf = lcfirst($str);
echo $lcf;
?>
Output :
Hello World!
hello World!

Example for ucfirst() String Function

<?php
$str = "hello world!";
echo $str . "<br />";

$ucf = ucfirst($str);
echo $ucf;
?>
Output :
hello world!
Hello world!

Example for strrev() String Function

<?php
$str = "hello world!";
echo $str . "<br />";

$rev = strrev($str);
echo "Reverse String : ".$rev;
?>
Output :
hello world!
Reverse String : !dlrow olleh

Example for strip_tags() String Function

<?php
$str = "<p><strong>Hello World!</strong></p>";
echo $str . "<br />";

$strt = strip_tags($str);
echo $strt;
?>
Output :
Hello World!


Hello World!

Example for chop() String Function

<?php
$str = "Hello World!";
echo $str . "<br />";

$ch = chop($str, "world!");
echo $ch;
?>
Output :
Hello World!
Hello W

Example for htmlentities() String Function

<?php
$str = "<p><strong>Hello World!</strong></p>";
echo $str . "
"; $ent = htmlentities($str); echo $ent; ?>
Output :
Hello World!


<p><strong>Hello World!</strong></p>