PHP code example of riimu / kit-baseconversion
1. Go to this page and download the library: Download riimu/kit-baseconversion library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
riimu / kit-baseconversion example snippets
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('A37334', 16, 2); // outputs: 101000110111001100110100
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('-1BCC7.A', 16, 10) . PHP_EOL; // outputs: -113863.625
echo BaseConverter::baseConvert('-1BCC7.A', 16, 10, 1); // outputs: -113863.6
imu\Kit\BaseConversion\BaseConverter;
$converter = new BaseConverter(16, 10);
echo $converter->convert('A37334') . PHP_EOL; // outputs: 10711860
echo $converter->convert('-1BCC7.A') . PHP_EOL; // outputs: -113863.625
$converter->setPrecision(1);
echo $converter->convert('-1BCC7.A'); // outputs: -113863.6
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('0.1', 3, 10) . PHP_EOL; // outputs: 0.33
echo BaseConverter::baseConvert('0.1', 3, 10, 6) . PHP_EOL; // outputs: 0.333333
echo BaseConverter::baseConvert('0.1', 3, 10, 12); // outputs: 0.333333333333
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('0.A7', 16, 10, 0) . PHP_EOL; // outputs: 0.652
echo BaseConverter::baseConvert('0.A7', 16, 10, -2); // outputs: 0.65234
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('7BFA11', 16, 12) . PHP_EOL; // outputs: 2879B29
echo BaseConverter::baseConvert('7bfa11', 16, 12); // outputs: 2879B29
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('7F', 16, 1024) . PHP_EOL; // outputs: #0127
echo BaseConverter::baseConvert('5Glm1z', 64, 512); // outputs: #456#421#310#371
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('101100011101', '01', 16) . PHP_EOL; // outputs: B1D
echo BaseConverter::baseConvert('101100011101', 2, '0123456789abcdef'); // outputs: b1d
imu\Kit\BaseConversion\BaseConverter;
echo BaseConverter::baseConvert('22', 10, ['nil', 'one']) . PHP_EOL; // outputs: oneniloneonenil
echo BaseConverter::baseConvert('187556', 10, ['-', '-!', '-"', '-#', '-¤', '-%']); // outputs: -¤---¤-!-%-"