sorry i think i did tell u wrong about it problem is not showing name of it as exaclty i just wanted give a point to it thats not real problem real problem is i want it be more unpossible when i give the class's add function's higher value 2008/11/22, Yeti <yeti@xxxxxxxxxx>: > That should output the full line now > <? > > $prExample = new probabilityRandom; > > > function arasi($a,$b,$data) > { > $x = explode($a,$data); > $z = explode($b,$x[1]); > $oh = $z[0]; > if($x && $z) { return $oh; } else { return false; } > } > > > $x="jZRBb9swDIXvA/YfdFyxHJK0GHadvc7tYUAQb+iZiWlHKGUFkpy1+/WTE7uzFcr1MSbz+NmPj1s4Om3E55X4tBKyFl/Wi+VyefPxQ0Zwwv/PV+vF3fl5epDO//5mlP/bBhoqjK4HfYv1Xdv2oyESGwKH0dbbVdu40U76p7oUuW6oK3299ZWEoPD/fkGGLtE1ipTQM5r3IQs7C3DYFsI9SVtoNcTLDBxAMWw5wesU1QOSQjeDKGy8MD35BtMilXDSxg6RfmmHSu5FfkTgPH0Ac9QjtwK0DJraEbo536vvjfJVBvY4xHts7U/0H4bsXEqNtnY3rId8idaz2IK+zkxZP4ut9EwpPHswq4DoZgh4T/JFGpE7KEvOWCBQUBd41fLGudVV4/XnZeTSPD8pAb+SRUE4eoH8AKZgyH9KAxWK71BV7Gay2FxqoshMdgJcAlONaTdGonXiUR1h7xjqrn7O+t6APbzPHstWhJtPWKapEDufoJ5n2V8dQmuxEL+Pfrf9bcr3RhNNAk0kKsIUyxU79OK6pPYMDokD4HtChbUDmoMcCVkEl41aaqSyfoO3eofXSql5tS3LuNp9e4NYT6e0F99AzXH26kE5Is+EqNeP7VI/ILI84YTrve8HZKRPOPEGYb0bQI13STd2OORaPOJir83alrs2av50kyyRSerMu9Z1zz5sCf7Vb7s7MY87SPFZzEUaqcbsjSnydo81J9Iek43FfSwccTMmyrj7Dw=="; > $x = gzinflate(base64_decode($x)); > $xx=explode(" > ",$x); > $xcx=array(); > > foreach($xx as $c => $y) > { > $yy = arasi(" in ",")",$y); > $yy = str_replace(",","",$yy); > $xcx[]=$yy; > #echo $yy."<br>"; > $itemisim = explode("(",$y); > $itemisim=$itemisim[0]; > $xcx[isim][]=$itemisim; > } > for($i=0;$i<=count($xcx)-1;$i++) > { > $prExample->add( $xx[$i], $xcx[$i] ); // <-- changed to $xx[i] > } > print $prExample->get(); > > class probabilityRandom { > #private vars > var > $data = array(), > $universe = 0; > #add an item to the list and defines its probability of beeing chosen > function add( $data, $probability ){ > $this->data[ $x = sizeof( $this->data ) ] = new stdClass; > $this->data[ $x ]->value = $data; > $this->universe += $this->data[ $x ]->probability = abs( $probability ); > } > #remove an item from the list > function remove( $index ){ > if( $index > -1 && $index < sizeof( $this->data ) ) { > $item = array_splice( $this->data, $index, 1 ); > $this->universe -= $item->probability; > } > } > #clears the class > function clear(){ > $this->universe = sizeof( $this->data = array() ); > } > #return a randomized item from the list > function get(){ > if( !$this->universe ) > return null; > $x = round( mt_rand( 0, $this->universe ) ); > $max = $i = 0; > do > $max += $this->data[ $i++ ]->probability; > while( $x > $max ); > return $this->data[ $i-1 ]->value; > } > } > ?> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php