Announcement

Collapse
No announcement yet.

How to split a string?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jeffct
    replied
    try chunk_split

    Leave a comment:


  • Mika
    replied
    Here's a dirty way to do it. I'm sure there's an elegant way somewhere

    If that string is $viite

    Code:
     $viite1 = substr($viite, -5, 5);
     $viite2 = substr($viite, -10, -5);
     $viite3 = substr($viite, -15, -10);
     $viite4 = substr($viite, -20, -15);
     
     $viiteuus = $viite4 . " " . $viite3 . " " . $viite2 . " " . $viite1;
    ... I know that $viite is <= 20 characters.

    Leave a comment:


  • Floris
    replied
    I am not a php guru, but maybe php.net has some information about function.spliti.php or just split, preg_split, etc.

    Hopefully that helps you on your way. Sorry if it doesn't.

    Leave a comment:


  • Mika
    started a topic How to split a string?

    How to split a string?

    I don't have any ideas how to do this so if there's anyone who can help me...

    I have a string that can be like 12487299823749874
    (length may vary)

    I need to modify that string so that those numbers are like 5 numbers and a space and then next the five and a space and... starting from RIGHT (to left).

    So the above should look like
    12 48729 98237 49874

    Anyone? Thanks!

Related Topics

Collapse

Working...
X