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.

Php

Discussion in 'Programming' started by wenkep3, Aug 6, 2010.

  1. #1
    I'm attempting to call the function inputFileTab which reads a text file and puts it into a 2d array, then return the array to the function that called it (contentResume), but so far nothing is being returned. Can anyone answer why?

    Thanks

    function contentResume(){
    inputFileTab("files/content/resume.txt", "");
    for($b=0;$b<count($contents);$b++){
    print("<a href=\"files/download/".$contents[$b][0].
    "\"><img src=\"".$contents[$b][1]."\"></a>");
    print("<br />");
    }
    }


    function inputFileTab($fileLocation, $nextFunction){
    $file=file($fileLocation);
    for($i=0;$i<count($file);$i++){
    $lineExplode=explode("\t",$file[$i]);
    for($x=0;$x<count($lineExplode);$x++){
    $contents[$i][$x]=$lineExplode[$x];
    }
    }
    if(function_exists($nextFunction)){
    $nextFunction($contents);
    }else{
    return($contents);
    }
    }
     
    wenkep3, Aug 6, 2010 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    Your syntax is wrong

    $nextFunction($contents);

    Looks like you are more familiar with javascript?

    You will need to eval(); it.
     
    Kaizoku, Aug 6, 2010 IP
  3. wenkep3

    wenkep3 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hows eval going to return the array created by inputFileTab to contentResume?
     
    wenkep3, Aug 6, 2010 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4

    Nah, this is actually valid syntax.
     
    nico_swd, Aug 10, 2010 IP