Viewed   103 times

I would like to know how can I add comma's to numbers. To make my question simple.

I would like to change this:




and :




and so on for larger numbers. Is it possible with a php function?



from the php manual

I'm assuming you want the english format.


$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation with a decimal point and without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57


my 2 cents

Saturday, August 27, 2022

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (

  -r, --register-only
        do not remove files, only register the packages as not installed

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022

You can customize vendor bundles through application config like that:

return [
    // ...
    'components' => [
        'assetManager' => [
            'bundles' => [
                'yiiwebYiiAsset' => [
                    'jsOptions' => ['condition' => 'lt IE 7'],
                'yiibootstrapBootstrapAsset' => [
                    'jsOptions' => ['condition' => 'lt IE 7'],

Or in runtime through assetManager:

use Yii;


Yii::$app->assetManager->bundles['yiiwebYiiAsset']->jsOptions = ['condition' => 'lt IE 7'];

Yii::$app->assetManager->bundles['yiibootstrapBootstrapAsset']->jsOptions = ['condition' => 'lt IE 7'];

Official docs:

  • Customizing Asset Bundles
Monday, November 21, 2022

Someone wanted a bit more detail on the stdClass() object, so here it is. I don't claim that this is a good way to code this problem. There are bound to be better ways.

    // Build scoreRequest from $answers (includes quizId)
    $scoreRequest = new SoapVar((array)$answers, SOAP_ENC_OBJECT, null, null, 'scoreRequest', $this->is);

    // SoapVar not used pass this point; see below.
    //$identityRequest = new SoapVar(array('scoreRequest' => $scoreRequest), SOAP_ENC_OBJECT, null, null, 'identityRequest');

    // scoreQuizRequest uses a mixture of SoapVar Objects and stdClass Objects.
    // stdClass Object is used to allow us to define the attributes for 
    // identityRequest, such as productAlias & transactionID.
    // Note: $scoreRequest is a SoapVar Object.
    $request = new stdClass();
    $request->identityRequest = new stdClass();
    $request->identityRequest->scoreRequest = $scoreRequest;

    $request->identityRequest->customerReference = $this->customerReference;
    $request->identityRequest->locale = $this->locale;
    $request->identityRequest->productAlias = $this->productAlias;
    $request->identityRequest->transactionID = $this->transactionId;
Saturday, October 29, 2022

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :