Hello guys. I made a form with 3 inputs (song name 1, song name 2 and album name). When i submit this form it calls a php script like this one:

<?php
$song1 = $_POST['song1'];
$song2 = $_POST['song2'];
$album = $_POST['album'];

$output = shell_exec('D:\\apache\\htdocs\\test\\mp3wrap\\mp3wrap.exe '.$album.' '.$song1.' '.$song2.'');
echo "<pre>$output</pre>";

?>

This merges the 2 song files into 1 song. I can add in the form more song name inputs, but i want php to automaticaly create arrays from inputs and add them to the shell_exec command. So how can i make the php script add the input arrays without me manually writing $song3 = $_POST; $song4 = $_POST;...etc?
Thanks

Store the song names in an array when fed from the form. E.g.:

<form method="post" action="">
    <!-- field labels and submit button excluded for simplicity -->

    <input type="text" name="song[]" />
    <input type="text" name="song[]" />
    <input type="text" name="song[]" />
    <input type="text" name="song[]" />
    <input type="text" name="song[]" />
    <input type="text" name="song[]" />
    <!-- etc... -->

    <input type="text" name="album" />
</form>

Then after form submission...

$songs = isset($_POST['song']) ? $_POST['song'] : array();
$album = isset($_POST['album']) ? $_POST['album'] : '';

// Remove empty song fields and implode
$songs = array_filter($songs);
$songs = implode(' ', $songs);

// You should make sure you validate values before executing them on your server
$output = shell_exec("D:\\apache\\htdocs\\test\\mp3wrap\\mp3wrap.exe {$album} {$songs}");

R.

thank you very much, it works...but how can i add a path to the mp3 folder? because $song will be in a folder called mp3 an my command line would look like this:
mp3wrap.exe album_name path/to/song1 path/to/song2 path/to/song3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.