Php 数组,foreach,向数组添加字符串 if($\u POST['op\u ep\u cat']='op\u single\u ep') { $ep_place=$_POST['the_place']; $eps_array=array(); 阵列推送($eps\U阵列,$EPP\U位置); } 如果($_POST['op_ep_cat']=='op_category'){ $cat_site=$_POST['the_place']; $take\u cat\u site=文件获取内容($cat\u site); 如果(preg_)匹配所有('#
试试这个Php 数组,foreach,向数组添加字符串 if($\u POST['op\u ep\u cat']='op\u single\u ep') { $ep_place=$_POST['the_place']; $eps_array=array(); 阵列推送($eps\U阵列,$EPP\U位置); } 如果($_POST['op_ep_cat']=='op_category'){ $cat_site=$_POST['the_place']; $take\u cat\u site=文件获取内容($cat\u site); 如果(preg_)匹配所有('#,php,arrays,string,foreach,Php,Arrays,String,Foreach,试试这个 if ($_POST['op_ep_cat'] == 'op_single_ep') { $ep_place = $_POST['the_place']; $eps_array = array(); array_push($eps_array, $ep_place); } else if ($_POST['op_ep_cat'] == 'op_category') { $cat_site = $_POST['the_place']; $ta
if ($_POST['op_ep_cat'] == 'op_single_ep')
{
$ep_place = $_POST['the_place'];
$eps_array = array();
array_push($eps_array, $ep_place);
}
else if ($_POST['op_ep_cat'] == 'op_category') {
$cat_site = $_POST['the_place'];
$taken_cat_site = file_get_contents($cat_site);
if (preg_match_all('#<div class="content_ep"><a href="(.+?)"#si', $taken_cat_site, $eps_array));
else if (preg_match_all('#<div class="postlist">\s*<a href="(.+?)"#si', $taken_cat_site, $eps_array));
}
foreach(array_reverse($eps_array[1]) as $eps_match)
{
echo 'Arughh!';
}
$eps\u数组[1]
不是数组,是$eps\u数组的元素
你可以做一个数组
if ($_POST['op_ep_cat'] == 'op_single_ep')
{
$ep_place = $_POST['the_place'];
$eps_array = array();
$eps_array[1] = array();
array_push($eps_array[1], $ep_place);
}
试着读一下什么是数组
$eps_array = array(1=>array());
array_push($eps_array[1], $ep_place);
但是整个代码都很奇怪。对于
op\u single\u ep
版本来说,$eps\u array[0]
应该是这样的。记住,PHP数组有基于0的索引。啊哈,忘了设置eps\u array[1]=array():)尝试了,得到了:array\u push()[function.array push]:第一个参数应该是数组,array\u reverse()[function.array reverse]:参数应该是一个数组,为foreach()提供的参数无效……哦,嗯……你能进一步阐述你的问题吗?XD你还没有提供到底什么不起作用。请打印$POST和$eps_数组以查看问题在preg push products下添加print_r($eps_array);
:数组([0] => http://xxxxx.com/xxxx )
…成功了!即使我读了整个手册,也无法创建它。谢谢!
$eps_array = array(1 => array($_POST['the_place']));