Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explode by special character ·

Tags:

php

I have string like this : Suède · Slovénie

I need to explode it by · i have tried various solutions like :

preg_split("/[?·]/",strip_tags($single->children(2)->outertext))

explode(chr(149), strip_tags($single->children(2)->outertext)); 

explode(utf8_encode('·'),strip_tags($single->children(2)->outertext));

explode('·',strip_tags($single->children(2)->outertext));

But none of solutions works for me! can any one please let me know?

like image 729
daniyalahmad Avatar asked Jun 01 '26 19:06

daniyalahmad


1 Answers

You shall rather use mb_split():

  var_dump(mb_split('·', 'Suède · Slovénie'));

gives

array(2) {
  [0]=>
  string(7) "Suède "
  [1]=>
  string(10) " Slovénie"
}
like image 146
Marcin Orlowski Avatar answered Jun 03 '26 09:06

Marcin Orlowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!