PHP Classes

File: README.txt

Recommend this page to a friend!
  Classes of Alex F. Bustos  >  SI Prefix Converter  >  README.txt  >  Download  
File: README.txt
Role: Documentation
Content type: text/plain
Description: Brief of how to use the class
Class: SI Prefix Converter
Convert a number to a string appending a prefix
Author: By
Last change: Update of README.txt
Date: 2 months ago
Size: 2,928 bytes


Class file image Download
File: readme.txt
Created by: Alex Bustos - @alexfbp

At first, Thanks for downloading and testing it.

This file is a little resume and explanation on how to use
this class. For specific details, see the class and demo files.


1. Include, instantiate and (opt) set the numeric and list limitations
	include(''); //Maybe you want to change some default values
	$sci=new sci('LOP'[,- more options-]); //See the __construct() function for details.
If the first argument of the construct is a variable, you must be sure that this variable
is sanitized, has not forbidden expressions such as "..", "/", etc...
The 'LOP' (List Of Prefixes) are the DESIRED list, not the used list which
are generated internally through a call to the start() function (step 4)

2. (opt) Set the numeric out format. By decimal places or significant digits

3. (opt) Insert Additive Rules

4.	$sci->start(); //the object.
Else, the main functions will return the unmodified value


mixed get_prefixed(mixed $value,bool $array=false):
	Returns a string like $number.$join.$prefix. based on a previously choosen
	List of Prefixes.
	The $join value was previously defined when instantiating the object.

	Or, if you want to format the prefix as you want, you can set $array=true,
	and the function will return an array($number,$prefix);

mixed get_number(string $string, bool $entities=true, $flags=ENT_COMPAT)
	If you want to do the inverse process, here comes that function.
	May return a float or a int.
	Prior to use this function, you should configure the charset.

sci::valid_list($LOP) - Basic validation if a List of Prefixes $LOP are in the allowed format.
set_round_params() - Rounding Configuration. See the class and then
set_charset($charset) - Valid Charset. See the $encoding arg of 

RULE FUNCTIONS: Add to the ALLOWED list, from the DESIRED list
(and if the exponent are valid in the specified range):

	set_single_rule($exponent); //a prefix of the same exponent
	set_scale_rule($scale); //each prefix multiple of $scale
Omitting the limits, ej:
with 3, allowed exps will have too {...,-9,-6,-3,0,3,6,9,...}
with 2, allowed exps will have too {...,-6,-4,-2,0,2,4,6,...}
and so...
	set_all_rule(); //All of the prefixes

If needed, to understand the differences between the allowed and desired lists,
var_dump an sci object, before and after to the call to start():

$sci=new sci();
... //Maybe you wish to add some rules
For more information send a message to info at phpclasses dot org.