Login   Register  
PHP Classes
elePHPant
Icontem

File: sample

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of benjamin RICHARD  >  Array Manipulation  >  sample  >  Download  
File: sample
Role: Documentation
Content type: text/plain
Description: How To Use the Class
Class: Array Manipulation
Manipulate data in array entries
Author: By
Last change: this is the new sample for the new class ArrayManip
Date: 10 years ago
Size: 2,809 bytes
 

Contents

Class file image Download
<?php
/**
 * HOW TO USE ARRAY MANIP
 * 
 * 1st of all you have to import the class
 * Then declare the object
 * And finally just call the different methods
 * 
 **/

// 1) import
require_once( "class.array.php");

$arrTestArray = array(
              array("theme_is_edited"=>0, "theme"=>"home", 
                            array("News", "news", 1, 0, 0),
                            array("Article", "article", 1, 1, 0),
                            array("Extranet", "extranet", 1, 0, 0),
                            array("Copyright", "copyright", 1, 0, 0)
                            ),
              array("theme_is_edited"=>0, "theme"=>"test", 
                            array("List", "list", 1, 0, 0),
                            array("Phpclass", "phpclass", 1, 0, 0),
                            array("Search", "search", 1, 0, 0),
                            array("File", "file", 0, 0, 1),                   ),
              array("theme_is_edited"=>0, "theme"=>"info", 
                            array("Heaven", "heaven", 1, 0, 0), 
                            array("History", "history", 1, 0, 0), 
                            array("Homemade", "homemade", 1, 0, 0) 
                            ),
              array("theme_is_edited"=>0, "theme"=>"link", 
                            array("Companies", "urlcie", 1, 0, 0), 
                            array("Associations", "urlassociation", 1, 0, 0),
                            array("Partnair", "urlpartnair", 1, 0, 0), 
                            array("Others", "urlperso", 1, 0, 0) 
                            ),
              array("theme_is_edited"=>0, "theme"=>"finally", 
                            array("The", "the", 1, 0, 1), 
                            array("End", "end", 1, 0, 0)
														)
														
              );
// 2) the object instanciation : new ArrayManip (default = 1 for indexed array, or 0 for mixed associated/indexed array)
$objTestArrayManip = new ArrayManip(1);

echo "<table><th>original</th><th>move</th><th>del</th><th>add</th><tr><td valign=\"top\">" ;
             
myPrint_r( $arrTestArray[0] );
 
echo "</td><td valign=\"top\">";

// 3)a-> move elements (the 3rd elements to the 5th)
myPrint_r( $objTestArrayManip->moveElement($arrTestArray[0], 0, 2) );

echo "</td><td valign=\"top\">";

// 3)b-> delete element (del the 3rd elements)
myPrint_r( $objTestArrayManip->deleteElement($arrTestArray[0], 3) );

echo "</td><td valign=\"top\">";

// 3)b-> insert elements (one element or an array)
myPrint_r( $objTestArrayManip->insertElement($arrTestArray[0], 1, array("ten", "eleven", "twelve")));

echo "</td></tr></table>";

function myPrint_r( $arArray ){
  echo("<pre>");
  print_r($arArray);
  echo("</pre>");
}
?>