jkkenzie Posted December 29, 2009 Share Posted December 29, 2009 Hi! From The code below, check the $array variable, i want it to accumulate arrays if the !empty conditon is fullfilled. What i want here is how do i accumulate the array?. This cant be the right way. Its not working. $array=array(); if(!empty($_FILES['FrontPic']) && !empty($_FILES['FrontPic']['name'])){ if(!empty($old_data) && !empty($old_data['FrontPic']) && file_exists($dir.$old_data['FrontPic'])) unlink($dir.$old_data['FrontPic']); $array ="'FrontPic'=>'FrontPic'"; } if(!empty($_FILES['SidePic']) && !empty($_FILES['SidePic']['name'])){ if(file_exists($dir.$old_data['SidePic']) && !empty($old_data) && !empty($old_data['SidePic'])) unlink($dir.$old_data['SidePic']); $array=."'SidePic'=>'SidePic'"; } if(!empty($_FILES['RearPic']) && !empty($_FILES['RearPic']['name'])){ if(!empty($old_data) && !empty($old_data['RearPic']) && file_exists($dir.$old_data['RearPic'])) unlink($dir.$old_data['RearPic']); $array=.array('RearPic'=>'RearPic'); } if(!empty($_FILES['Pic4']) && !empty($_FILES['Pic4']['name'])){ if(!empty($old_data) && !empty($old_data['Pic4']) && file_exists($dir.$old_data['Pic4'])) unlink($dir.$old_data['Pic4']); $array=.array('Pic4'=>'Pic4'); } Link to comment https://forums.phpfreaks.com/topic/186575-accumulate-arrays/ Share on other sites More sharing options...
Buddski Posted December 29, 2009 Share Posted December 29, 2009 to add a value to an array you can use $array[] or $array['key'] For example. if(!empty($old_data) && !empty($old_data['FrontPic']) && file_exists($dir.$old_data['FrontPic'])) unlink($dir.$old_data['FrontPic']); $array['FrontPic'] = 'FrontPic'; } Link to comment https://forums.phpfreaks.com/topic/186575-accumulate-arrays/#findComment-985326 Share on other sites More sharing options...
jkkenzie Posted December 29, 2009 Author Share Posted December 29, 2009 Erro unexpected '[', expecting '(' in when i use $array['FrontPic'] = 'FrontPic'; Link to comment https://forums.phpfreaks.com/topic/186575-accumulate-arrays/#findComment-985334 Share on other sites More sharing options...
Buddski Posted December 29, 2009 Share Posted December 29, 2009 can you show the whole changed code.. Link to comment https://forums.phpfreaks.com/topic/186575-accumulate-arrays/#findComment-985335 Share on other sites More sharing options...
jkkenzie Posted December 29, 2009 Author Share Posted December 29, 2009 You were right, i had some other syntax error. No works. Thanks Link to comment https://forums.phpfreaks.com/topic/186575-accumulate-arrays/#findComment-985384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.