1

I have this two variable that I combined

${$monthNamelower . $category[$k]}= $row['COUNT(mycategory)'];//example output decStationery

if my $category[$k] is more than two words

Example Electrical Appliance

How do I remove the space using str replace so it would be

ElectricalApplicance instead of Electrical Appliance ?

Ali
  • 3,373
  • 5
  • 42
  • 54
gtroop
  • 295
  • 4
  • 13
  • String replace usually works like that: str_replace('replace"this', 'with_this', 'in_this_string');. Optionally add .count at the end to check how many times it did the transform. – g00dy Jul 10 '17 at 08:18
  • Possible duplicate of [How to strip all spaces out of a string in php?](https://stackoverflow.com/questions/2109325/how-to-strip-all-spaces-out-of-a-string-in-php) – Bibhudatta Sahoo Jul 10 '17 at 08:18

1 Answers1

2

You can use preg_replace Just like this

$category[$k] = preg_replace('/\s+/', '', $category[$k]);
Bibhudatta Sahoo
  • 4,808
  • 2
  • 27
  • 51