PHP code example of dantleech / symfony-form-array-to-delimited-string-transformer

1. Go to this page and download the library: Download dantleech/symfony-form-array-to-delimited-string-transformer 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/ */

    

dantleech / symfony-form-array-to-delimited-string-transformer example snippets


$form->add(
    $builder->create('tags', 'text')->addModelTransformer(
        new ArrayToDelimitedStringTransformer()
    )
);

// Tranform
array('one', 'two', 'three', 'four') === 'one, two, three, four'

// Reverse transform
'   one ,  two    , three, four,' === array('one', 'two', 'three', 'four')

new ArrayToDelimitedStringTransformer(';')

// Transform
array('one', 'two', 'three', 'four') === 'one; two; three; four'

// Reverse Transform
'one   ; two;three ;     four' => array('one', 'two', 'three')

new ArrayToDelimitedStringTransformer('%', 1, 1)

// Transform
array('one', 'two', 'three', 'four') === 'one % two % three % four'

// Reverse Transform
'one   % two%three %     four' => array('one', 'two', 'three')