<h1>ldif2array examples</h1>
<pre><font color=green>/*
* Example to read LDIF file
* @package ldif2Array
* @author tobozo at phpsecure
* @date 2006-12-13
*/</font></pre><?
error_reporting(E_ALL);
/*
* Example to read LDIF file
* @package ldif2Array
* @author tobozo
* @date 2006-12-13
*/
require("ldif2array.class.php");
$file = "users.ldf";
// Example 1, using filename
$ld = new ldif2array($file,true);
print ("<h2>Example 1, using filename</h2>");
$code = '<?'.'
require("ldif2array.class.php");
$file = "users.ldf";
$ld = new ldif2array($file,true);
print_r($ld->entries);
'.'?>';
highlight_string($code);
print ("<pre><h3>Resulting array : </h3>");
print_r($ld->entries);
print ("</pre><br>");
$code = '<?'.'
require("ldif2array.class.php");
$file = "users.ldf";
$ld = new ldif2array();
$ld->rawdata = file_get_contents($file);
if($ld->makeArray()) {
print_r($ld->getArray());
}
'.'?>';
// Example 2, using data
$ld = new ldif2array();
$ld->rawdata = file_get_contents($file);
print ("<h2>Example 2, using data</h2>");
if($ld->makeArray()) {
highlight_string($code);
print ("<pre><h3>Resulting array : </h3>");
print_r($ld->getArray());
print ("</pre>");
}
|