我正在编写一个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 )
和Line#B:
36031P.mp4 hello.mp4
此时此刻,点击任何表格行中的Go按钮,所有mp4文件到mp3的转换开始发生(这不是我的要求)
问题陈述:
我想知道我应该在上面的html/php代码中做什么更改,以便如果我在屏幕截图中从上面的第一行点击Go按钮,第一行 mp4文件到mp3的转换应该开始发生,反之亦然。
https://stackoverflow.com/questions/56467383
复制相似问题