Quick actions

cmd+k|ctrl+k

Navigation

Languages

Comma-sparated items to array with PHP

Snippet info

Language

Php

Visibility

public

Author

mertskaplan

Created

2020-08-15T15:25:50Z

Updated

2020-08-15T15:25:50Z

<?php


$a = 'journalist,press, media,news,';

function commaSparatedItems2Array($text) {
    return json_decode(str_replace(',""','', '["'. str_replace(',','","',$text) .'"]'), true);
}


print_r(commaSparatedItems2Array($a));
INFO