Posted By:
16 Mar, 2014 3:01 am PDT

Some more methods to handle string in PHP

// To replace the String and to display the sub-string of the given String

 

<!DOCTYPE html>

<html>

<body>

<?php

$strold="JAVA  PROGRAMMING !!";

$strnew=str_replace("JAVA","PHP",$strold);

echo "<br>",$strnew,"</br>";

$str="This is String Handling in PHP";

$sub=substr($str,8,15);

echo $sub;

?>

</body>

</html>

 

/*Output of the above program is:

PHP PROGRAMMING !!

String Handling

*/

Attachment:None


This shows how to use and handle some other functions of string like str_replace() and substr().

Attachment: Stringhandling.php
Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud