php array to string and string to array
php array to string and string to array |
Hi Friends today we are going to learn how to convert an array into string or convert a string into array using php..
here we will use php explode and php implode method to perform array to string or string to array..
string to array: php explode
<?php $data='Thank You for visiting Codenair'; echo '<div><b>Your String</b></div>'; echo $data; $explode=explode(' ',$data); echo '<div><b>String To Array</b></div>'; print_r($explode); //You can Get Each Words form array echo '<div><b>Each Words from Array</b></div>'; foreach($explode as $row){ echo $row.'<br/>'; } ?>
php string to array |
That's it How to convert php string to array
php array string: php implode
$data=array('Thank','You','for','visiting','Codenair'); $implode=implode('separator',$data);
You can separate words using dash,dot etc..
Just Follow the below php implode example:
<?php $data=array('Thank','You','for','visiting','Codenair'); $implode_dash=implode(' ',$data); $implode_plus=implode('+',$data); $implode_minus=implode('-',$data); $implode_dollar=implode('$',$data); $implode_equal=implode('=',$data); echo '<div><b>Array to String</b></div>'; echo $implode_dash.'<br/>'; echo $implode_plus.'<br/>'; echo $implode_minus.'<br/>'; echo $implode_dollar.'<br/>'; echo $implode_equal.'<br/>'; ?>
php array to string and string to array |
Thank You..Keep Visiting..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.