Solved

Array in an Array

Posted on 2007-11-14
5
222 Views
Last Modified: 2008-02-01
When I am retrieving the value for the $_FILES super global I am getting Array returned.  How do I get the value of the elements inside the array to get returned?

<label for="file"><strong>File:</strong> <?php echo $details['file'] ?></label><br />

Form
<?php foreach ($cars as $car => $details) { ?>
<h3><?php print $car ?></h3>
  <label for="format"><strong>Format:</strong> <?php echo $details['format'] ?></label><br />
  <label for="rotation"><strong>Rotation(%):</strong> <?php echo $details['rotation'] ?></label><br />
  <label for="size"><strong>Size:</strong>
  <?php echo $details['724x90']; ?> &nbsp;
  <?php echo $details['300x250']; ?> &nbsp;
  <?php echo $details['160x600']; ?></label> &nbsp; &nbsp; &nbsp;
  <label for='other'><strong>Other:</strong> <?php echo $details['othertx'] ?> </label><br />
  <label for="layout"><strong>Layout:</strong> <?php echo $details['layout'] ?></label><br />
  <label for="bannerlink"><strong>Banner Link:</strong> <?php echo $details['bannerlink'] ?></label><br />
  <label for="file"><strong>File:</strong> <?php echo $details['file'] ?></label><br />
  <label for="dspecific"><strong>Deal Specifics:</strong> <?php echo $details['dspecific'] ?></label><br />
  <label for="disclaimer"><strong>Disclaimer:</strong> <?php echo $details['disclaimer'] ?></label><br /><br /><br />
<?php  }  ?>

0
Comment
Question by:taynet29
  • 2
  • 2
5 Comments
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 350 total points
ID: 20283129
$_FILES['name_your_file_field']['name'] will give you the name of the uploaded file.

$_FILES['name_your_file_field']['type'] gives you the type

$_FILES['name_your_file_field']['size'] gives you the size

$_FILES['name_your_file_field']['tmp_name'] gives you the temporary name the file is stored in ...
For example to move the file to your server you would do

move_uploaded_file($_FILES['name_your_file_field']['tmp_name', 'destination/directory/name_of_file.jpg')

$_FILES['name_your_file_field']['error'] gives you the error if any
0
 
LVL 11

Assisted Solution

by:jgordos
jgordos earned 150 total points
ID: 20283138
Generally, you can print the entire array by just

print_r($a);

where $a is the array.

I'm not sure, exactly, what you're asking.

0
 
LVL 11

Assisted Solution

by:jgordos
jgordos earned 150 total points
ID: 20283153
0
 

Author Comment

by:taynet29
ID: 20283532
All the arrays are being printed on the "Work Order Review" page.  All I am asking is how do I get the variable to print as an array.  Keep in mind it is being stored as an Array in $details.  Then the $_FILES array.  As a result, <?php echo $details['file'] ?> prints ---> Array.  

What I have tried is
<?php if(isset($_FILES["file"][0])) ?>
<?php if(isset($_FILES["file"]["name"])) ?>
<?php if(isset($details["file"][1])) ?>
<?php if(isset($details["file"]["name"])) ?>

They all do not return a value.

Please let me know what I am doing incorrectly.  How do I print the file name?
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 350 total points
ID: 20283816
<?php echo $details['file']['name_of_field']['name'] ?> should do it
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now