【发布时间】:2019-10-21 08:54:21
【问题描述】:
我正在编写如下所示的 html/php 代码。在其中单击 html 代码中的按钮时,它会进入 php 中 Line#B 处的 foreach 块。
<?php
$mp4_files = array_values($mp4_files);
print_r($mp4_files); // Line #A
if($_SERVER['REQUEST_METHOD'] == "POST")
{
foreach ($mp4_files as $f) // Line#B
{
// conversion of mp4 into mp3 is happening, not pasting the full code.
}
}
?>
<form action="" method="POST">
<table>
<tr>
<th>MP4 Name</th>
<th>Action</th>
</tr>
<?php
$mp4_files = array_values($mp4_files);
foreach ($programs as $key => $program) {
$file = $mp4_files[$key];
print_r($file); // Line#B
?>
<tr>
<td><?php echo basename($file); ?></td>
<td><button type="submit" name="go-button" value="Go">Go</button</td>
</tr>
<?php } ?>
</table>
</form>
以上html/php代码显示如下内容:
在上面的屏幕截图中,我们列出了 mp4 文件及其各自的按钮。
Line#A 从上面的 html/php 代码中打印出以下数组:
Array ( [0] => 36031P.mp4 [1] => hello.mp4 )
还有线#B:
36031P.mp4 hello.mp4
此时,点击任何表格行中的 Go 按钮,开始将所有 mp4 文件转换为 mp3(这不是我的要求)
问题陈述:
我想知道我应该在上面的 html/php 代码中进行哪些更改,以便如果我从屏幕截图中的 第一行 中单击 Go 按钮,转换第一行 mp4 文件转换为 mp3 应该开始发生,反之亦然
【问题讨论】:
标签: php arrays ajax post foreach