title: Trying to replace height and width values in PHP
body: <p>Trying to replace height="" and width="" values in a string($content) with PHP, i've tried preg replace to no avail, 
  and suggestions on what i'm doing wrong?</p>
  
  <p>Sample content would be:</p>
  
  <pre><code>$content = '&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/c0sL6_DNAy0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;';
  </code></pre>
  
  <p>Code below:</p>
  
  <pre><code>if($type === 'video'){
  
          $s = $content;
          preg_match_all('~(?|"([^"]+)"|(\S+))~', $s, $matches);
  
          foreach($matches[1] as $match){
  
              $newVal = $this-&gt;_parseIt($match);
      preg_replace($match, $newVal, $s);
  
          }
  
      }
  </code></pre>
  
  <p>Here i just take the match and search for my height and width</p>
  
  <pre><code>function _parseIt($match)
  {
      $height = "height";
      $width = "width";
  
      if(substr($match, 0, 5) === $height){
  
          $pieces = explode("=", $match);
          $pieces[1] = "\"175\"";
  
          $new = implode("=", $pieces);
          return $new;
  
      } 
  
      if(substr($match, 0, 5) === $width){
  
          $pieces = explode("=", $match);
          $pieces[1] = "\"285\"";
  
          $new = implode("=", $pieces);
          return $new;
  
      }
  
      $new = $match;
      return $new;
  
  }
  </code></pre>
  
  <p>There's probably a much shorter way to do this, however, I really just picked up programming 6 months ago.</p>
  
  <p>Thanks in advance!</p>