im stumped as to how to do this ive searched previous posts etc, metioning Split & Ereg?

but the php site examples make no sense

i have a string sent from a form it will be like:

SA1234

i need to split it into a new variable and i bassicaly need to drop the SA so i am left with 1234 as a new variable?

    Is SA a prefix ? I mean, does the string contain always two characters and number ?

      the string will always contain SA followed by 4 number so it will always b 6 chars long

      same prefix everytime only the number changes

        <?php
        
        $string='SA1234';
        
        $prefix=substr($string,0,2);
        $num=substr($string,2,6);
        
        ?>

        I think this will work.

          Flyier wrote:
          <?php
          
          $string='SA1234';
          
          $prefix=substr($string,0,2);
          $num=substr($string,2,6);
          
          ?>

          I think this will work.

          that worked perfect thanks, i tried writing the code myself and it wouldnt work

            If you want to save a few keystrokes:

            $num = stubstr($string, 2);
            

            (If no 3rd arg, substr() will grab from the specified string position to the end of the string.)

              Write a Reply...