dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: javascript array to php

  1. #1
    Join Date
    Nov 2011
    Posts
    7

    javascript array to php

    hi i have a array defined in javascript.
    how can i use the array in php.
    i tried the following but it isn't working.
    contactcid[i] is the javascript array.

    <?php
    echo "<script language=\"javascript\">\n";
    echo "$y = 'http://apis.live.net/V4.1/cid-'".contactcid[i]+."'/Photos/Albums\'";
    $html = file_get_html($y);
    // haal de url op en zet het in $html
    // zoek alle img tags op de url in $html en zet ze in $element
    foreach($html->find('img') as $w)
    {

    // en zet ze in beeld
    echo "<img src='".$w->src."' width='75' height='75' /><br/>";
    }
    ?>

    thanks

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    You can't. JavaScript runs when the code reaches the browser, PHP well before that. What you can do is define the array in PHP, use PHP to output it to JavaScript, and then you'll have free use of the array in both.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles