title: Negative Number preg_match_all
body: <p>Hi All im One function to convert ltr css to rtl but not work correct by any format my function is</p>
  
  <pre><code>public function rtlMargin($string)
  {
      $string = trim($string);
      if (preg_match_all('~(-[0-9]+(px|%)?)~i', $string, $matches)) {
          $c = count($matches['1']);
          $p = $matches['1'];
          if ($c == 4)
              $order = implode(' ', array(
                  $p['0'],
                  $p['3'],
                  $p['2'],
                  $p['1']));
          else
              if ($c == 3)
                  $order = implode(' ', array(
                      $p['0'],
                      0,
                      $p['2'],
                      $p['1']));
              else
              if ($c == 2)
                  $order = implode(' ', array(
                      $p['0'],
                      0,
                      0,
                      $p['1']));
              else
              if ($c == 2)
                  $order = implode(' ', array(
                      $p['0'],
                      0,
                      0,
                      $p['1']));
              else                
                  $order = implode(' ', $p);
  
          if (preg_match('/auto/',$string)) {
              return 'margin: ' . $order . ' auto;' . '&lt;br /&gt;';
          }
          else
          {
              return 'margin: ' . $order . ';' . '&lt;br /&gt;';
          }            
      }
  
      return $string;
  }
  </code></pre>
  
  <p>Code Test Function Is
      $res .= $MyConverter->rtlMargin("margin:1px 2px 3px 4px");</p>
  
  <p>Output is
  margin:1px 4px 3px 2px;</p>
  
  <p>But </p>
  
  <pre><code>$res .= $MyConverter-&gt;rtlMargin("margin:1-px 2px 3-px 4px");
  </code></pre>
  
  <p>Output is Empty Bug For</p>
  
  <pre><code>if (preg_match_all('~(-[0-9]+(px|%)?)~i', $string, $matches))
  </code></pre>