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() 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