"something here ; and there, oh,that's all!"
I want to split it by ;
and ,
so after processing should get:
something here and there oh that's all!
You can get the values into an array using Devin's or Meder's method. echo implode("\n", $resultingArray); Or use <br /> if it's HTML you want.
Delimiters ¶ A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character. Leading whitespace before a valid delimiter is silently ignored. Often used delimiters are forward slashes ( / ), hash signs ( # ) and tildes ( ~ ). The following are all examples of valid delimited patterns.
<?php $pattern = '/[;,]/'; $string = "something here ; and there, oh,that's all!"; echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With