gpt4 book ai didi

php - 如何通过在 php 中使用 anchor 将数组传递到另一个页面

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:03:11 25 4
gpt4 key购买 nike

我必须使用 <a href> 将数组值从一个 php 页面传递到另一个 php 页面...这是我的代码

$cluster是一个数组

echo "<td><a href=myebon.php&cluster[]=".$cluster.">Click here to OFF</a></td>";

myebon.php

$n=count($_GET[cluster]);
for($i=0;$i<=$n;$i++)
{
echo $cluster[$i]=$_GET['cluster'][$i];
}

该值在第二页中不可访问,它显示为数组而不是值。我也尝试过序列化概念......

最佳答案

这是清晰的示例代码

首先.php

<?php
$Mixed = array("1","2","3");
$Text = json_encode($Mixed);
$RequestText = urlencode($Text);
?>
<a href="second.php?cluster=<?php echo $RequestText; ?>">Click</a>

second.php

<?php
$Text = urldecode($_REQUEST['cluster']);
$Mixed = json_decode($Text);
print_r( $Mixed);
?>

我已经检查过了,它工作正常。

关于php - 如何通过在 php 中使用 anchor 将数组传递到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14979882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com