1. Go to this page and download the library: Download aveiv/mixed-value 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/ */
class StripSpacesProcessor implements ValueProcessorInterface
{
public function __invoke($value)
{
if (!is_string($value)) {
throw new UnexpectedValueException('Value must be a string');
}
return str_replace(' ', '', $value);
}
}
$mixed = new MixedValue([
'bad_float' => '9 999.99',
]);
$mixed->registerValueProcessor('stripSpaces', new StripSpacesProcessor());
$mixed['bad_float']->stripSpaces()->toFloat()->getValue(); // return 9999.99
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.