Browsing articles tagged with "split string Archives - PHP Dev Tips"
Jul
18
2011
18
2011
Exploding a String using Multiple Delimiters Using PHP
Updated February 12th, 2013 to reflect Dave’s comment function below- A++ for simplicity! function explodeX( $delimiters, $string ) { return explode( chr( 1 ), str_replace( $delimiters, chr( 1 ), $string ) ); } $list = ‘Thing 1&Thing 2,Thing 3|Thing 4’; $exploded = explodeX( array(‘&’, ‘,’, ‘|’ ), $list ); echo ‘<pre>’; print_r($exploded); echo ‘</pre>’; Earlier today, I was looking for a simple function to explode text that was contained in string format to be output […]
Recent Snippets
- htaccess : Only allow access to specific wordpress upload types if logged in
- MySQL : Query WordPress Database for Invalid Media Filenames
- PHP : Get Actual IP Address with PHP
- JavaScript : Allow Tab in Textarea
- PHP : Clean sanitized database contents on output
- htaccess : Force www. prefix in URIs
- PHP : Force File Download with Correct Content Type
- Wordpress : Disable upgrade notification