Good evening. I produce a whois parsing, I get the data, then I arrange it on the output:

enter image description here

I want to remove spaces in the beginning, I tried everything (regexp, str_replace, trim, ltrim). Maybe the problem is in the encoding? And what's the gap in another encoding? In general, I'm confused help who knows.

  • one
    Lay out the normal code, not the picture. And show exactly how to remove spaces. - PinkTux
  • trim should work fine. Try to display strings character-by-code (codes). If there is a problem with the coding, there will be "not a space (32)" codes. You can add them to trim arguments - DNS

1 answer 1

Try this trim () replacement:

$text = preg_replace('%^\s+|\s+$%u', '', $text); 

PS You have the most likely pages in UTF-8, for this you need to specify the u modifier for php in the regular schedule.

  • It worked great, thanks. - G.Denis