Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match horizontal ellipse (…) in php

Tags:

regex

php

php-5.3

I want to replace the horizontal ellipse (…) with three period (...)in a given string.
Till now I have tried are:

str_replace('…','...', $text);
str_replace('…', '...', $text);
str_replace('&hellips', '...', $text);

But not able to get the desired output. Can you please suggest some method for it.

EDIT:
One more problem I am facing related to this is when I paste the ~…~u character in my editor (I am using Editplus). the ... are converted into a rectangle. (see screenshot). enter image description here

Thanks

like image 419
jimy Avatar asked May 20 '13 09:05

jimy


2 Answers

try to use preg_replace with the /u modifier (the string is treated as an unicode string):

$result = preg_replace('~…~u', '...', $string);
like image 97
Casimir et Hippolyte Avatar answered Sep 27 '22 21:09

Casimir et Hippolyte


Try This

str_replace('…', '...', htmlentities($text));
like image 31
Sudz Avatar answered Sep 27 '22 23:09

Sudz