Split() problem in Php

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

  1. #1
    i need to reveive all words in text file after : i started to write this code for example i need to receive frisco415 :
    text file:
    :frisco415
    :friekiegee
    :linkage9

    <?php

    $filename="w.txt";
    $content=file($filename);
    foreach($content as $line) {
    //echo $line."<br>";
    $linew= split(":",$line);
    //print_r($linew);
    for($i=0;$i<count($linew);$i++){
    echo $linew[$i]"<br>";
    }
    }

    ?>
     
    ssimon171078, Oct 24, 2014 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    As long as there won't be any usernames with : you would be pretty save doing this

    
    <?php
    $filename="w.txt";
    $content=file($filename);
    foreach($content as $line) {
        $linearray = explode(":",$line);
        if (isset($linearray[1])) {
            echo $linearray[1].'<br/>';
        }
    }
    
    ?>
    
    PHP:
     
    Anveto, Oct 24, 2014 IP