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.

array conffusing

Discussion in 'PHP' started by 123extra, Jun 6, 2008.

  1. #1
    sorry though, im still noob in this, here is my problem:

    i get the arrays from links.txt
    $file = "links.txt";
    $lines = file($file); // read file values as array in php
    
    PHP:
    the link.txt :
    
    http://blablabla
    http://somedomain
    http://anotherdomain
    
    Code (markup):
    i want to display it back for javascript like this :
    
    var links = array (
    'http://blablabla',
    'http://somedomain',
    'http://anotherdomain'  //no comma after last link
    )
    
    Code (markup):
    i have use
    var links = Array(<? echo implode("','",$lines) ?>);
    PHP:
    but it show like this:
    
    var links = array (http://blablabla
    ','http://somedomain
    ','http://anotherdomain
    )
    
    Code (markup):
    im so desperate ive googleing but still no luck :confused:
     
    123extra, Jun 6, 2008 IP
  2. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try
    var links = Array(<? echo("'".implode("','",$lines)."'" ?>);
    PHP:
    I'm still not sure that will solve your problem, though. *thinking*
     
    Altari, Jun 6, 2008 IP
  3. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #3
    that's the sollution yes! start and end also with '
     
    EricBruggema, Jun 7, 2008 IP
  4. 123extra

    123extra Peon

    Messages:
    1,502
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok thanks, it working. i really love this forum. theres so many nice people here :D
     
    123extra, Jun 7, 2008 IP