PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Ming Choi   Array Class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Array Class
Manipulate numeric array values
Author: By
Last change: update to 0.2
Date: 14 years ago
Size: 1,416 bytes
 

Contents

Class file image Download
<pre><?php
//Array Class Example
include "array.class.php";
$ArrayClass = new ArrayClass();

$numbers = array(1,1,1,2,2,2,2,2,3,4,5,6,7,8,9,5,4,3);

echo
"\n MAX:";
var_dump($ArrayClass->array_max($numbers)); //get the max. value of an array

echo "\n MIN:";
var_dump($ArrayClass->array_min($numbers)); //get the min. value of an array

echo "\n SUM:";
var_dump($ArrayClass->array_sum($numbers)); //get the sum of an array

echo "\n AVG:";
var_dump($ArrayClass->array_avg($numbers)); //get the avg. value of an array

echo "\n MODE:";
var_dump($ArrayClass->array_mode($numbers)); //get the mode value of an array

echo "\n FIRST QUARTILE:";
var_dump($ArrayClass->array_firstQuartile($numbers)); //get the first quartile of an array

echo "\n MEDIAN/SECOND QUARTILE:";
var_dump($ArrayClass->array_median($numbers)); //get the median/second quartile value of an array

echo "\n THIRD QUARTILE:";
var_dump($ArrayClass->array_thirdQuartile($numbers)); //get the third quartile of an array

echo "\n ASC ORDER:";
var_dump($ArrayClass->array_order($numbers, true)); //get array in ascending order

$stringarray = array(array("a", "b"), array("c", "d"));

echo
"\n ARRAY TO STRING:";
$str = $ArrayClass->array2str($stringarray, true); //change a array to a string
var_dump($str);

echo
"\n STRING TO ARRAY:";
var_dump($ArrayClass->str2array($str)); //recover a array to a string
?>