Posted By

chrisaiv on 11/23/09


Tagged

php


Versions (?)

PHP: Simple Dynamic Variable Example


 / Published in: PHP
 

  1. <?php
  2.  
  3. /*
  4. How to dynamically cast a variable
  5. */
  6.  
  7. $a = 'kevin';
  8. $b = 'mary';
  9. $c = 'joe';
  10. $d = 'larry';
  11. $e = 'audrey';
  12.  
  13. $students = array('a', 'b', 'c');
  14.  
  15. foreach( $students as $seat ){
  16. echo $$seat . "<br />";
  17. }
  18.  
  19.  
  20. ?>

Report this snippet  

You need to login to post a comment.