Str Replace and Adding Space?
<p>I used one solution to fix one problem, then when I went to fix another problem, it made the other problem occur again. </p>

<p>I'm currently using this to replace spaces with dashes. </p>

<pre><code>$var2 = str_replace(' ', '-', $var2);
</code></pre>

<p>Now say <code>$var2</code> is an address, so 5019 Hill Street. I had it set to add a %20 to numerals so that it would say it as <code>5 0 1 9</code>. When I put the <code>str_replace</code> to add the dash, it screwed this up.</p>

<p>Is there a way to put within the string replace, both functions? I was using this to add the space between numerals.</p>

<pre><code>if(is_numeric($var2)){
 $var2 = addSpaceToStr($var2);
}

function addSpaceToStr($str){
 $strLen = strlen($str);
 $strWithSpace = '';
 for($i = 0; $i &lt;$strLen; $i++){
  $strWithSpace .= $str[$i];
  if(($i+1) != $strLen){
   $strWithSpace .= '%20';
  }
 }
 return $strWithSpace;
}
</code></pre>

<p>These are in two different files, so I tried different variations of putting them in just one file without success. As well as keeping them in separate files without success either. The first file curls over the variable with the dashes added, then the second file is suppose to add spaces to the numbers, but now it's not adding the spaces to the numbers. Any ideas?</p>

<p>Thanks!</p>
