So I have a text file with sets of 4 items I want to go in different arrays. I've tried the following but without success.

<?php
$urls="list.txt";
$page = join("",file("$urls"));
$kw = explode("|", $page);
$count = 0;
$links = array();
$images = array();
$widths = array();
$heights = array();
for($i=0;$i<count($kw);$i++){
    $count++;

    if ($count==1){
        $links[$i] = array($kw[$i]);
    }

    if ($count==2){
        $images[$i] = array($kw[$i]);
    }

    if ($count==3){
        $widths[$i] = array($kw[$i]);
    }

    if ($count==4){
        $heights[$i] = array($kw[$i]);
        $count = 0;
    }

}

?>

I'm not sure where my logic is wrong, but when I print the arrays out I dont get anything.
Thanks in advance.

edit: forgot to give an example of what is in the file;

imgur.com | link.gif | 40 | 80 | google.com | ebay.jpg | 42 | 129 |

Did you ever solve this?

Try this

<?php
$urls="list.txt";
$page = join("",file("$urls"));
$kw = explode("|", $page);
$count=0;
$arrayRow=0;
$links = array();
$images = array();
$widths = array();
$heights = array();

foreach($kw as $key=>$vl) {
    $count++;
    if ($count==1)    $links[$arrayRow] = $vl;

    if ($count==2)     $images[$arrayRow] = $vl;

    if ($count==3)     $widths[$arrayRow] = $vl;

    if ($count==4){
        $heights[$arrayRow] = $vl;
        $count = 0;
        $arrayRow++;
    }
}

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.