Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between space and whitespace in PHP?

Tags:

php

What is the difference between space and whitespace in PHP?

I saw on different places that to strip out all the spaces use str_replace() and use preg_replace() for whitespace.

Here is a reference: https://stackoverflow.com/a/2109339/4003463

like image 598
Kayani Avatar asked Feb 03 '23 23:02

Kayani


1 Answers

In the added context to your question, a space is ascii 32 (that is, what you get when you press the spacebar).

A whitespace is any character that renders as a space, that is:

  • A space character
  • A tab character
  • A carriage return character
  • A new line character
  • A vertical tab character
  • A form feed character
like image 73
Federico klez Culloca Avatar answered Feb 06 '23 16:02

Federico klez Culloca