dimanche 28 juin 2015

Pass a string into an array PHP

I have list of strings like this:

'PYRAMID','htc_europe','htc_pyramid','pyramid','pyramid','HTC','1.11.401.110 CL68035 release-keys','htc_europe/pyramid/pyramid:4.0.3/IML74K/68035.110:user/release-keys'

It looks like elements of an array, But when i use

<?php
    $string = "'PYRAMID','htc_europe','htc_pyramid','pyramid','pyramid','HTC','1.11.401.110 CL68035 release-keys','htc_europe/pyramid/pyramid:4.0.3/IML74K/68035.110:user/release-keys'";
    $arr = array($string);
    print_r($arr);

 ?>

It doesnt work as I want:

Array ( [0] => 'PYRAMID','htc_europe','htc_pyramid','pyramid','pyramid','HTC','1.11.401.110 CL68035 release-keys','htc_europe/pyramid/pyramid:4.0.3/IML74K/68035.110:user/release-keys')

Instead of:

Array ( [0] => PYRAMID, [1] => htc_europe, [2] => htc_pyramid, ...

I dont want to use explode() because my strings are already in array format and many strings have the ',' character. Please help me, thanks.

Aucun commentaire:

Enregistrer un commentaire