You are viewing an old revision of this post, from September 20, 2013 @ 00:27:39. See below for differences between this version and the current revision.

How to convert a string to an array in php

[php] $str="this is string"; $array=explode(" ",$str); print_r($array); ?> Array ( [0] => this [1] => is [2] => string )[/php]

Revisions

Revision Differences

September 20, 2013 @ 00:27:39Current Revision
Content
Unchanged: [php]Unchanged: [php]
Deleted: <pre><?php 
Unchanged: $str="this is string";Unchanged: $str="this is string";
Unchanged: $array=explode(" ",$str);Unchanged: $array=explode(" ",$str);
Unchanged: print_r($array);Unchanged: print_r($array);
Unchanged: ?>Unchanged: ?>
Unchanged: ArrayUnchanged: Array
Unchanged: (Unchanged: (
Unchanged: [0] => thisUnchanged: [0] => this
Unchanged: [1] => isUnchanged: [1] => is
Unchanged: [2] => stringUnchanged: [2] => string
Deleted: )</pre> 
Deleted: [/php] Added: )[/php]

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags: , , ,

No comments yet.

Leave a Reply