刚注意到,如果我不选择复选框并提交,我会收到这些错误:
Warning: implode() [function.implode]: Invalid arguments passed in /home/content/o/l/t/oltvcb/html/feedback_mtg.php on line 148
Warning: Cannot modify header information - headers already sent by (output started at /home/content/o/l/t/oltvcb/html/feedback_mtg.php:148) in /home/content/o/l/t/oltvcb/html/feedback_mtg.php on line 162
我注意到表格数据实际上是在我的电子邮件中发现的......
与"选项"字段有关
下面是表单代码:
#<?php
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;
$mailto = 'xxxxx@xxxxxxxxx.com' ;
// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" …Run Code Online (Sandbox Code Playgroud) $array = array('item1', 'item2', 'item3', 'item4', 'item5');
在这里,我想只提取数组中的前三项,然后
$implodes = implode(';', $array);
echo $implodes;
Run Code Online (Sandbox Code Playgroud)
哪个应该输出
item1;item2;item3
$i=0;
$new = array();
foreach($array as $arr)
{
$i++;
if($i <= 3)
{
$new[] = $arr;
}
}
Run Code Online (Sandbox Code Playgroud)
看起来不太漂亮
我有以下代码,用于循环在表单上提交的名称:
$row_count = count($_POST['name']);
if ($row_count > 0) {
mysql_select_db($database, $connection);
$name = array();
$workshop = array();
for($i = 0; $i < $row_count; $i++) {
// variable sanitation...
$name[i] = mysql_real_escape_string(ucwords($_POST['name'][$i]));
$workshop[i] = mysql_real_escape_string($_POST['workshop'][$i]);
}
$names = "('".implode("','",$name)."')";
.....etc
Run Code Online (Sandbox Code Playgroud)
出于某种原因$names,只返回表单上提交的姓氏,而不是所有姓名.有人可以帮助我正常工作吗?
谢谢,
缺口
我使用以下内容在用户注册后将电子邮件地址退回到自动发送电子邮件.如果只有1个结果,那么在php中正确的LoadResultArray列表会崩溃吗?或者,如果只有1个结果,我是否必须写一个例外?
$query = "SELECT u.email FROM " . $table_prefix . "users as u, " . $table_prefix . "bl_teamcord as tc WHERE FIND_IN_SET('$team_id',tc.teams) AND tc.u_id = u.id AND tc.reg_emails = 1";
$db->setQuery($query);
$remail2 = $db->loadResultArray();
if ($remail2){
$remail3 = implode(",",$remail2);
}else{
$remail3 = "";}
Run Code Online (Sandbox Code Playgroud)
另外,电子邮件功能可能有问题吗?
$to = $remail3;
Run Code Online (Sandbox Code Playgroud) <?php
$player = $_GET['player'];
$data = explode(" ", file_get_contents("http://hiscore.runescape.com/index_lite.ws?player={$player}"));
print_r($data);
?>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,这会返回
Array ( [0] => 322788,1584,39425065 474211,75,1213741 424332,73,1044331 497032,75,1223804 518140,74,1127869 622836,53,146813 484601,51,114656 540925,65,452516 276405,78,1772587 614588,62,339049 85477,99,13069655 135438,86,3702239 69906,99,13034532 376565,60,294135 403376,55,173156 413268,62,349011 339269,50,103575 388661,52,125891 452907,52,134281 402625,50,102104 281390,50,109948 236592,63,377586 385212,50,103894 329955,50,104225 320731,50,103833 286842,50,101634 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 )
Run Code Online (Sandbox Code Playgroud)
检索的原始数据file_get_contents是
322790,1584,39425065 474214,75,1213741 424335,73,1044331 497037,75,1223804 518145,74,1127869 622844,53,146813 484604,51,114656 540930,65,452516 276407,78,1772587 614595,62,339049 85477,99,13069655 135439,86,3702239 69906,99,13034532 376567,60,294135 403379,55,173156 413272,62,349011 339272,50,103575 388664,52,125891 452909,52,134281 402629,50,102104 281392,50,109948 …Run Code Online (Sandbox Code Playgroud) 有一种简单的方法,最好是单线程,以破坏阵列范围.
例:
array(1,4,6,88,51,3,5,48,59,4);
Run Code Online (Sandbox Code Playgroud)
另外,我怎么能只在第一个和第三个值之间崩溃?
我正在使用Nette Framework,我有这个命令在起作用:
$id = is_array($id) ? implode(', ', $id) : $id;
$this->database->table('manufacturing')->where('id', $id)->update(array('trash' => '1'));
Run Code Online (Sandbox Code Playgroud)
当我在网格中选择4行并调用此操作来删除项目时,它将生成以下SQL代码:
UPDATE `manufacturing`
SET `trash`='1'
WHERE (`id` = '31, 32, 33, 34')
Run Code Online (Sandbox Code Playgroud)
但我需要这样的代码来更新所有行:
UPDATE `manufacturing`
SET `trash` = '1'
WHERE ((`id` = '31') OR (`id` = '32') OR (`id` = '33') OR (`id` = '34'));
Run Code Online (Sandbox Code Playgroud)
内爆功能可以吗?谢谢.
编辑:当我做这个:
$id = is_array($id) ? implode(' "OR" ', $id) : $id;
Run Code Online (Sandbox Code Playgroud)
它会这样做:
UPDATE `manufacturing`
SET `trash`='1'
WHERE (`id` = '31 \"OR\" 32 \"OR\" 33 \"OR\" 34')
Run Code Online (Sandbox Code Playgroud) 我的意见是这样的:
$str = ' 1. Admin, Administrator,3. Visor, Super,4. Team, Super User,5. lastname, employee'
Run Code Online (Sandbox Code Playgroud)
如何使用数组爆炸产生以下输出?
array(
[0] => Array ( [0] => 1 [1] => Admin [2] => Administrator)
[1] => Array ( [0] => 3 [1] => Visor [2] => Super)
[2] => Array ( [0] => 4 [1] => Team [2] => Super User)
[3] => Array ( [0] => 5 [1] => lastname [2] => employee)
)
Run Code Online (Sandbox Code Playgroud) 我想使用implode通过以下数组显示逗号分隔的一系列链接:
数组名称:
$product['product_category']
Run Code Online (Sandbox Code Playgroud)
数组的数据:
Array (
[0] => Array (
[name] => Apparel
[href] => http://localhost/uooro/index.php?route=profile/category&path=12
)
[1] => Array (
[name] => Business Services
[href] => http://localhost/uooro/index.php?route=profile/category&path=15
)
[2] => Array (
[name] => Chemicals
[href] => http://localhost/uooro/index.php?route=profile/category&path=16
)
)
Run Code Online (Sandbox Code Playgroud)
我希望得到这样的结果:
Apparel, Business Services, Chemicals
Run Code Online (Sandbox Code Playgroud) 我有这样的数组
$test=Array ( [0] => en [1] => fr )
Run Code Online (Sandbox Code Playgroud)
当我使用这个命令
$a=implode(",",$test);
print_r($a);
Run Code Online (Sandbox Code Playgroud)
结果是:
英语,法语
但我想要这个结果
'恩', 'FR'
我有一个像这样的关联数组:
$myarray = array('a' => 1, 'b' => 2, 'c' => 3);
Run Code Online (Sandbox Code Playgroud)
我想显示数组键和值,如下所示:
a is 1, b is 2, c is 3
Run Code Online (Sandbox Code Playgroud)
我不想使用 print_r 或 var_dump 来执行此操作。我也不想使用 foreach 循环。我只想使用一个简短的代码,我已经尝试过:
echo implode('', $myarray);
Run Code Online (Sandbox Code Playgroud)
但这也不起作用,因为我只能显示键或只能显示数组的值。