refiking Posted December 4, 2012 Share Posted December 4, 2012 I'm working on a zip archive script that works if I have no conditions. The second I check it against teh post data and try to render out a line, it doesn't work anymore. Not sure what I'm doing wrong. Here is the code with no conditions: $files = array( array('name'=>'file1', 'title'=>'file1', 'path' => 'file1.msi'), array('name'=>'file2','title'=>'file2', 'path' => 'file2.msi'), ); Here is what I'm trying to do: $postfiles = $_POST;if($postfiles['file1'] == 1){ $arrayme .= "array('name'=>'file1','title'=>'file1', 'path' => 'file1.msi'),";}if($postfiles['file2'] == 1){ $arrayme .= "array('name'=>'file2', 'title'=>'file2', 'path' => 'file2.msi'),";}$files = array( $arrayme,);[code] Link to comment https://forums.phpfreaks.com/topic/271570-not-sure-if-its-the-array-or-the-syntax/ Share on other sites More sharing options...
refiking Posted December 4, 2012 Author Share Posted December 4, 2012 Oops. I meant to enclose the code block $postfiles = $_POST;[/font][/color] if($postfiles['file1'] == 1){ [/font][/color] $arrayme .= "array('name'=>'file1','title'=>'file1', 'path' => 'file1.msi'),";[/font][/color] }[/font][/color] if($postfiles['file2'] == 1){ [/font][/color] $arrayme .= "array('name'=>'file2', 'title'=>'file2', 'path' => 'file2.msi'),";[/font][/color] }[/font][/color] $files = array([/font][/color] $arrayme,[/font][/color] ); Link to comment https://forums.phpfreaks.com/topic/271570-not-sure-if-its-the-array-or-the-syntax/#findComment-1397370 Share on other sites More sharing options...
RobertP Posted December 4, 2012 Share Posted December 4, 2012 not sure what you are trying to do exactly here, but maybe this will help... $files = array(); for ($i = 1; $i <= $_POST['file_count']; $i++) { $files[] = array( 'name' => $_POST['file' . $i . '-name'], 'title' => $_POST['file' . $i . '-title'], 'path' => $_POST['file' . $i . '-path'], ); } Link to comment https://forums.phpfreaks.com/topic/271570-not-sure-if-its-the-array-or-the-syntax/#findComment-1397402 Share on other sites More sharing options...
refiking Posted December 4, 2012 Author Share Posted December 4, 2012 What you wrote gave me an idea. Here is what I am trying to do basically... $files = array(); if($postfiles['file1'] == 1){ $files[] = array('name'=>'file1','title'=>'file1', 'path' => 'file1.msi'); } if($postfiles['file2'] == 1){ $files[] = array('name'=>'file2', 'title'=>'file 2', 'path' => 'file2.msi'); } Link to comment https://forums.phpfreaks.com/topic/271570-not-sure-if-its-the-array-or-the-syntax/#findComment-1397412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.