PHP Classes

File: ldif2array_example.php

Recommend this page to a friend!
  Classes of tobozo   LDIF 2 Array   ldif2array_example.php   Download  
File: ldif2array_example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: LDIF 2 Array
Parse LDIF data into arrays
Author: By
Last change:
Date: 18 years ago
Size: 1,278 bytes
 

 

Contents

Class file image Download
<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>");
}