im pretty new to PHP scripting, and i couldnt find the answer to my desires yet, so i was hoping someone could tell me how to do this.
Im getting a $_POST request to a php file, containing some data
stock_nr=1&manufacturer=Audi&model=A1&images=http%3A%2F%2Fimages0.wheeler.nl%2Fs1386081049%2F6911582-1-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081072%2F6911582-2-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081102%2F6911582-3-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081131%2F6911582-4-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081161%2F6911582-5-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081192%2F6911582-6-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081227%2F6911582-7-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081255%2F6911582-8-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081280%2F6911582-9-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081313%2F6911582-10-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081341%2F6911582-11-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081368%2F6911582-12-2-2.jpg%2Chttp%3A%2F%2Fimages0.wheeler.nl%2Fs1386081398%2F6911582-13-2-2.jpg
I have made a file to declare variables like this:
$stock_nr=$_POST['stock_nr'] ;
$manufacturer=$_POST['manufacturer'] ;
$model=$_POST['model'] ;
$images=$_POST['images'] ;
How can i get the amount of imagelinks which are posted in a variable?
Edit: This is what i wanted to do, and it works fine.
This is what i wanted to do, and it does what it should do:
function process_images() {
$images = explode(',', $_POST['images']);
foreach($images as $image_nr => $image_url) {
$filename = 'images/'. $_POST['stock_nr'] .'-'. $image_nr .'.jpg';
$imgdata = file_get_contents($image_url);
file_put_contents($filename, $imgdata);
}
}