PHP/PHP Programming
[PHP] GET방식으로 배열(Array) 전송하기
사악미소
2017. 12. 22. 11:57
[PHP] GET방식으로 배열(Array) 전송하기
iframe 창을 띄우는 과정에서 넘겨야 할 값이 배열인 경우가 발생하였다.
그래서 GET방식으로 배열을 보내는 과정을 정리해 보았다.
01. GET값을 전송할 페이지
get_transmit.php |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script type="text/javascript"> function receiveFrameUrl() { var url = "./get_receive.php?idx[1]=아이린&idx[2]=슬기&idx[3]=웬디&idx[4]=조이&idx[5]=예리" jQuery("#receiveFrame").attr("src", url); } </script> <head> <title>GET방식으로 배열 전송</title> <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script> </head> <body> <input type="button" onClick="receiveFrameUrl();" value="전송"/> <br/> <iframe id="receiveFrame" width="100%" height="100%" frameborder="0" allowfullscreen></iframe> </body> </html> |
02. GET값을 전송받을 페이지
get_receive.php |
<?php echo "<pre>"; print_r($_GET['idx']); echo "</pre>"; ?> |
출력결과는 아래와 같다.
