Skip to content

Instantly share code, notes, and snippets.

@ccarpenterg
Created August 31, 2009 04:23
Show Gist options
  • Save ccarpenterg/178276 to your computer and use it in GitHub Desktop.
Save ccarpenterg/178276 to your computer and use it in GitHub Desktop.
<?php
class Gestor {
Private $arr;
Private $largo;
function __construct($arreglo) {
$this->arr = $arreglo;
$this->_largo();
}
Private function _largo() {
$this->largo = count($this->arr);
}
Public function elementos() {
echo $this->largo;
}
Public function promedio() {
$sum = 0;
$this->_largo();
foreach($this->arr as $valor) {
$sum += $valor;
}
$prom = $sum / $this->largo;
echo $prom;
}
}
$arreglo = array(3, 12, 34);
$obj = new Gestor($arreglo);
$obj->largo = 5;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment