Is there a php function to remove space inside a string? for example: $ abcd = "this is a test" I want to get the line: $ ABCD = "thisisatest"
How to do it? Thank you
Following will work
$abcd="this is a test"; $abcd = preg_replace('/( *)/', '', $abcd); echo $abcd."\n"; //Will output 'thisisatest';
or
$abcd = preg_replace('/\s/', '', $abcd);
See the manual http://php.net/manual/en/function.preg-replace.php
$abcd = str_replace(' ', '', 'this is a test');
See http://php.net/manual/en/function.str-replace.php
$string = preg_replace('/\s+/', '', $string);
Source: https://habr.com/ru/post/1307372/More articles:Pattern Matching - numericalDatamapper clone record with new identifier - cloneCalling R Script from C code - c ++Import Python wildcards from import names - pythonPHP: merging two separate mysql queries into the same json data object - jsonImplementing an online waiting room - ruby-on-railsEnable XSD in Jar with Maven? - maven-2Is it possible to determine which operating system the user is using using PHP? (Mac or windows) - phpAchieving NHibernate Nested Transaction Behavior - nhibernateUpdating rows using the in operator in the where clause - sqlAll Articles