Pages

Monday, April 27, 2015

function to manipulate string example in PHP

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php 3 ex</title>
</head>
<body>
 
 
   <?php
    // strlen() return length of string
    // str_word_count()  return character count of string
    // strrev()     return reverse of string
    // strpos()     search text from a string, return position of char. if not found return false
    // str_replace()  replace character in string


    echo strlen("toro tero");    // 9
    echo str_word_count("toro tero mgi");  //3
    echo strrev("gokil");    //likog
    echo strpos("hello guys im a developer", "develop");  //16
    echo str_replace ("here","over","hey you there please come here"); //hey you tover please come over


    ?>
 
</body>
</html>

No comments:

Post a Comment