{"id":368,"date":"2020-08-13T00:59:00","date_gmt":"2020-08-13T04:59:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=368"},"modified":"2020-12-24T01:02:14","modified_gmt":"2020-12-24T06:02:14","slug":"php-replacing-multiple-spaces-with-one-space","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/php-replacing-multiple-spaces-with-one-space\/","title":{"rendered":"PHP: replacing multiple spaces with one space"},"content":{"rendered":"\n<p>See the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$str = 'This    string    has   many   spaces';\n$str = preg_replace('\/\\s+\/', ' ', $str);\nprint $str;<\/code><\/pre>\n\n\n\n<p>output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>This string has many spaces<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>See the following code: output<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[24,135],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-php","tag-php","tag-regular-expressions"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=368"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/368\/revisions\/369"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}