String Manipulation : Dynamic Function « Functions « PHP






String Manipulation

 
<html>
 
 <head> 
  <title>String Manipulation</title> 
 </head>

 <body>

  <form action="strings.php" method="post">
  <b>Enter some text here:</b><br>
  <textarea name="txt" rows="3" cols="45"></textarea> <br>
  <input type="radio" name="fcn" value="strlen">Find the text length
  <input type="radio" name="fcn" value="strrev">Reverse the text<br>
  <input type="radio" name="fcn" value="strtoupper">Change to all uppercase
  <input type="radio" name="fcn" value="strtolower">Change to all lowercase<br>
  <input type="radio" name="fcn" value="ucwords">Make the first letter of all words uppercase
  <hr>
  <input type="submit" value="Manipulate"> 
  </form>

 </body>

</html>

File: strings.php




<html>
 <head>
  <title>String Result</title>
 </head>
 <body>
 <?php 

 $txt = $_POST['txt'];
 $fcn = $_POST['fcn'];
 echo( $fcn( $txt ) ); ?>

 </body>
</html>
  
  








Related examples in the same category

1.Calling Functions Dynamically
2.Calling a Function Dynamically
3.Calling Variable Functions
4.Calling a Function Dynamically
5.Creating Dynamic Functions
6.return the function name from a function call or calculation
7.Variable function example
8.Variable Function Names
9.Using a variable function determined by some input variable
10.Using Arrays of Lambda Functions