You are viewing an old revision of this post, from October 18, 2013 @ 00:13:14. 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

October 18, 2013 @ 00:13:14Current Revision
Content
Deleted: [php]<?php Added: [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
Unchanged: )[/php]Unchanged: )[/php]

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

Tags: , , ,

No comments yet.

Leave a Reply