1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Split

Discussion in 'Programming' started by ssimon171078, Oct 11, 2014.

  1. #1
    i need to split string to 25 chars each line in Php:
    <?php
    $text = "AAAAAAAAAAaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAaaaaaaaaa";
     
    ssimon171078, Oct 11, 2014 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    This will give you an array with each item begin 25 characters long

    
    $array = str_split($text, 25);
    print_r($array);
    
    PHP:
    Then you can just call on whatever part you need
    
    $array = str_split($text, 25);
    echo $array[0]; //Highest index could be calculated by original string length or just use count() on array
    //or use it in a loop
    foreach ($array as $part) {
        echo $part."<br/>";
    }
    
    PHP:
     
    Anveto, Oct 11, 2014 IP