How to replace slashes from the beginning and the end?
So, for example, all of them:
/what's this/
/what's this
what's this/
////////what's this////////////
... become: this / that
Use trim , and the second argument is the character (s) you want to trim.
$result = trim('/this/that//', '/'); //$result is now 'this/that'
Use ltrimand rtrim:
ltrim
rtrim
$txt = '////////this/that////////////'; echo rtrim(ltrim($txt, '/'), '/');
Result:
this/that
Source: https://habr.com/ru/post/1751010/More articles:How to change colors for F # interactive shell in Visual Studio 2010 - visual-studio-2010JQuery returns a JSON object with 404 - jsonдвухсторонняя привязка wpf datagrid к базе данных - data-bindingHow to issue an HTTP POST request? - phpДвойной индекс в Perl, почему это так? - arraysWhy ruby processes are 100% CPU on the passenger - ruby | fooobar.comAccess to a private variable in the global scope - c ++Создание табло на больших участках трафика - phpSimple C / C ++ Library for Triangle Intersection Acceleration Patterns - geometryVisual Studio 2010 - WDP or Publish for Auto Deployment? - asp.netAll Articles