# Cleaning up a string and convert to array

**URL:** <https://forum.kirupa.com/t/cleaning-up-a-string-and-convert-to-array/315202>\
**Category:** Uncategorized\
**Created:** [October 20, 2010, 7:03am UTC](https://forum.kirupa.com/t/cleaning-up-a-string-and-convert-to-array/315202 "2010-10-20T07:03:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavetriesPHP](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DavetriesPHP](https://forum.kirupa.com/u/DavetriesPHP)\
**Post date:** [October 20, 2010, 7:03am UTC](https://forum.kirupa.com/t/cleaning-up-a-string-and-convert-to-array/315202/1 "2010-10-20T07:03:11Z")

</div>

Hello, perhaps can you point me to a previous discussion (I searched) for the best way to clean up a string and convert to an array. I’ll be asking people to insert tags with commas between tags, just like here on this forum ; “Separate tags using a comma.” I assume I want to replace beginning spaces with nothing, replace double spaces with single, then explode like this.  
$tag\_array = explode(",", $tag);

Thanks for any links to definitive answers !
