3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*自己的選項*/ $url[] = array('url' => 'http://tw.yahoo.com','option' => 'yahoo.tw'); $url[] = array('url' => 'http://cn.yahoo.com','option' => 'yahoo.cn'); ?> <html> <head> <script> function chglink() {document.getElementById("link").innerHTML = document.getElementById("addr").value;} function chgFrame() {document.getElementById("iframe1").src = document.getElementById("link").innerHTML;} </script> </head> <body> 自己的選項 <?php print_r($url);?> <hr> <table border="1"> <tr><td>有select表單</td></tr> <tr><td>php在table內<select id="addr" onchange="chglink();"> <?php foreach($url as $k => $v) echo '<option value="'.$v["url"].'">'.$v["option"].'</option>'; ?> </select></td></tr> <tr><td>會顯示url(<a id="link" href="#" onclick="chgFrame();"></a>),請點我控制iframe</td></tr> <tr><td><iframe id="iframe1" src="<?php echo $url[0]["url"];?>" width="600px" height="400px"></td></tr> </table> </body> </html>

preferences:
27.2 ms | 404 KiB | 5 Q