SimpleXML Example Output:


SimpleXML Example Code:

<?php
    
// set name of XML file
    
$file '../sub/lists/currency.xml';
    
    
// load XML file
    
$xml simplexml_load_file($file) or die ('Unable to load XML file!');

    echo 
'<select name="currency" dir="rtl">';

    
// iterate over <sin> element collection
    
foreach ($xml as $currency) {
        echo 
'<option value="' $currency->ISO '">';
        echo 
$currency->Arabic "</option>\n";
    }

    echo 
'</select>';
    
$xml null;
?>

SQLite Example Output


SQLite Example Code:

<?php
  
try {
      
/*** connect to SQLite database ***/
      
$dbh = new PDO('sqlite:../sub/lists/lists.db');
          
      echo 
'<p align="center"><select name="currency" dir="rtl">';
  
     
/*
      * You will have noticed that we can iterate over the result set directly
      * with foreach. This is because internally the PDO statement implements 
      * the SPL traversble iterator, thus giving all the benifits of using SPL.
      *       
      * The greatest benifit of this is that SPL iterators know only one element 
      * at a time and thus large result sets become manageable without hogging 
      * memory.
      */             
      
foreach ($dbh->query('select * from currency') as $row) {
          echo 
'<option value="' $row['ISO'] . '">';
          echo 
$row['Arabic'] . "</option>\n";
      }
  
      echo 
'</select></p>';
      
      
// Close the databse connection
      
$dbh null
  } catch(
PDOException $e) {
      echo 
$e->getMessage();
  }
?>

Total execution time is 0.0036840438842773 seconds
Amount of memory allocated to this script is 136704 bytes

Names of included or required files: