[英]Dynamic Content in PHP array
This should be a quick one. 这应该是一个快速的过程。
I'm pulling a list of id's and I need to place them in an array. 我要提取一个id列表,我需要将它们放在数组中。
Here is my php code to get the list of id's 这是我的PHP代码,以获取ID的列表
$get_archives = mysql_query("SELECT * FROM archive WHERE user = '$email' ");
while ($row = mysql_fetch_assoc($get_archives)) {
$insta_id = $row['insta_id'];
$insta_id = "'" . $insta_id."',";
echo $insta_id;
};
This echo's a list of id's that looks like this: '146176036','136514942', 该回显是一个ID列表,如下所示:'146176036','136514942',
Now I want to put that list into an array. 现在,我想将该列表放入数组中。 So i tried something like this:
所以我尝试了这样的事情:
$y = array($insta_id);
However that isn't working. 但是,这是行不通的。 Any suggestions?
有什么建议么?
$y = array();
while ($row = mysql_fetch_assoc($get_archives)) {
$y[] = $row['insta_id'];
}
$myArray = array();
$get_archives = mysql_query("SELECT * FROM archive WHERE user = '$email' ");
while ($row = mysql_fetch_assoc($get_archives)) {
$insta_id = $row['insta_id'];
$insta_id = "'" . $insta_id."',";
$myArray[] =$insta_id;
};
did you mean like this: ? 您的意思是这样的吗?
$insta_id=array();
while ($row = mysql_fetch_assoc($get_archives)) {
$insta_id[] = $row['insta_id'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.