title: How to Remove a specific character from the end of the string in php
body: <p>How to Remove a specific character from the end of the string in php</p>
  
  <pre><code>$string = 'سلام-تست-است-';
  </code></pre>
  
  <p>i want change like</p>
  
  <pre><code>$string = 'سلام-تست-است';
  </code></pre>
  
  <p>so end of the سلام-تست-است we have Extra characters " - " and i want to remove it.</p>
  
  <p>and this is my code :</p>
  
  <pre><code> foreach($tag as $t){
              $t =  str_replace(' ', '-', $t);
              if(substr($t, -1) == '-'){
                $t   = rtrim($t,"-");
              }
              $insert_value[] = '("'.$content_id.'","'.$t.'","'.time().'")';
          }
  </code></pre>
  
  <p>$tag is my string .
  any idea? </p>