Skip to main content

Posts

Showing posts with the label foreach

PHP For Each Download File

I'm either using incorrect syntax or going about this with the wrong method. In the html document that references this php file, there is a simple list of checkboxes. The user checkmarks the boxes and hits submit. This then kicks off with the goal of prompting the user to run or save each file. If I checkmark test1.txt, test2.txt and test3.txt, there should be a popup for each (assuming of course the browser is IE). The issue is that only the 'last' checkmarked item is downloaded - the rest are not. I thought of opening a popup window for each file found but it has no effect. If I use echo $filename, it then correctly displays each entry I checkmarked so the php script appears to be given the multiple file names correctly. Can someone point me in the right direction? I'm pretty sure the $filename in the window.open parameter is not being used in the right syntax right now too. Here is the script: <?php foreach($_POST['files'] as $filename) { echo &quo

Is there any Relation between Iterator.hasNext and for-each loop

I was using JProfiler for profiling of my application, as it is a huge application so I am very aware of its performance and efficiency. It was taking too long so I replace all Iterator.hasNext with for-each but when I am seeing in the JProfilers CPU view it is showing me Iterator.hasNext method called where I am using for-each . Why does so? Is there any relation between these two? Here is the example code : List<Map<String, Object>> mapList = jdbcTemplate .queryForList(MAP.SELECT_ALL); for (Map<String, Object> map : mapList) { list.add(fillPreferenceMaster(preferenceMasterMap)); }