PHP Classes

File: examples/Misc.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   PHP Dictionary to Array class   examples/Misc.php   Download  
File: examples/Misc.php
Role: Example script
Content type: text/plain
Description: example script
Class: PHP Dictionary to Array class
Manipulate value collections as arrays or objects
Author: By
Last change:
Date: 6 years ago
Size: 3,872 bytes
 

Contents

Class file image Download
<?php
require_once('./../xdict.class.php');
echo
'<pre>';
highlight_string('<?php
$x=xdict(0);
for ($i=0;$i<5;$i++){
    $x[]=$i*3;
}

$y=new xDict();

var_dump(
is_xdict($x),
is_xdict($y),
is_xdict(new Exception()),
is_xdict(4)
);

?>'
);
$x=xdict(0);
for (
$i=0;$i<5;$i++){
   
$x[]=$i*3;
}

$y=new xDict();

var_dump(
is_xdict($x),
is_xdict($y),
is_xdict(new Exception()),
is_xdict(4)
);
highlight_string('<?php
$x->swap(0,4);
$x->rotate(3);
$x->rotate(2);
$x->rotate(-4);
$x->insert(2,"this is the new 2 value and the previous has been assigned to 3");
echo(count($x))."<br>";
var_dump(
$x->contains(0,3,9,12,30),
$x->contains(0,3,9,12,31),
$x->contains(9,12,3),
$x->in_xdict(42),
$x->in_xdict(30),
$x->in_xdict(\'mamamia\')
);
echo json_encode($x,JSON_PRETTY_PRINT|JSON_FORCE_OBJECT)."<br>";
?>'
);

$x->swap(0,4);
$x->rotate(3);
$x->rotate(2);
$x->rotate(-4);
$x->insert(2,31);
echo(
count($x))."<br>";
var_dump(
$x->contains(0,3,9,12,30),
$x->contains(0,3,9,12,31),
$x->contains(9,12,3),
$x->in_xdict(42),
$x->in_xdict(30),
$x->in_xdict('mamamia')
);
echo
json_encode($x,JSON_PRETTY_PRINT|JSON_FORCE_OBJECT)."<br>";

highlight_string('<?php
$x->rewind();
while(list($k,$v)=$x->each()){
    echo $k.":".gettype($v)."<br>"; //just to test each method but you can use $x->typesof() to know all the used types even recursively
}
?>'
);

$x->rewind();
while(list(
$k,$v)=$x->each()){
    echo
$k.":".gettype($v)."<br>"; //just in order to test each method but you can use $x->typesof() to know all the used types even recursively
}

highlight_string('<?php
var_dump(
$x->signature(),
$x->typesof(),
$x->homogeneous(),
$x->rowsandcol(),
$x->depth(),
$x->min(),
$x->max(),
$x->pseudoMiddle(true),
$x->sum(),
$x->product(),
$x->join(\'_\'),
$x->hash()
);
?>'
);

var_dump(
$x->signature(),
$x->typesof(),
$x->homogeneous(),
$x->rowsandcol(),
$x->depth(),
$x->min(),
$x->max(),
$x->pseudoMiddle(true),
$x->avg(),
$x->sum(),
$x->product(),
$x->join('_'),
$x->hash()
);


highlight_string('<?php
$r=xdict(0,\'k\');
$r->range(1,5,2);
$r->print_xr();
$r->range(\'a\',\'z\',2);
$r->print_xr();

?>'
);


$r=xdict(0,'k');
$r->range(1,5,2);
$r->print_xr();
$r->range('a','z',2);
$r->print_xr();

highlight_string('<?php
$r=xdict(0);
$r->range(1,20,2);
// $r->print_xr();
var_dump($r->pseudoMiddle(true),$r->pseudoMiddle());
$r=xdict(0);
$r->range(1,120,2);
// $r->print_xr();
var_dump($r->pseudoMiddle(true),$r->pseudoMiddle());
$r=xdict(0);
$r->range(0,120,2);
$r->shuffle();
// $r->print_xr();
var_dump($r->pseudoMiddle(true));
$r=xdict(0);
$r->range(\'a\',\'z\',2);
// $r->print_xr();
var_dump($r->pseudoMiddle(true)); //return null because there are no numeric in this xDict object
$r=xdict(0);
$r->range(-75,45.6,12.6);
$r->print_xr();
var_dump($r->pseudoMiddle(true));
?>'
);
$r=xdict(0);
$r->range(1,20,2);
// $r->print_xr();
var_dump($r->pseudoMiddle(true),$r->pseudoMiddle());
$r=xdict(0);
$r->range(1,120,2);
// $r->print_xr();
var_dump($r->pseudoMiddle(true),$r->pseudoMiddle());
$r=xdict(0);
$r->range(0,120,2);
$r->shuffle();
// $r->print_xr();
var_dump($r->pseudoMiddle(true));
$r=xdict(0);
$r->range('a','z',2);
var_dump($r->pseudoMiddle(true)); //return null because there are no numeric in this xDict object$r=xdict(0);
// $r->print_xr();
$r=xdict(0);
$r->range(-75,45.6,12.6);
$r->print_xr();
var_dump($r->pseudoMiddle(true));


highlight_string('<?php
$r=xdict(0,\'\',true,false,6);//pay attention to the last argument for it force the xDict object to have a limited length: here 6
$r->range(1,20,2);
$r->print_xr();
?>'
);
$r=xdict(0,'',true,false,6);//pay attention to the last argument for it force the xDict object to have a limited length: here 6
$r->range(1,20,2);
$r->print_xr();
?>