String Manipulation : Dynamic Function « Functions « PHP

String Manipulation

  <title>String Manipulation</title> 


  <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
  <input type="submit" value="Manipulate"> 



File: strings.php

  <title>String Result</title>

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


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