SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member Dolby's Avatar
    Join Date
    Jun 2003
    Location
    Wisconsin
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question foreach() result as a $varaible

    Here is a simple script I made to help me understand how foreach works. How can I store the output of the foreach to a $varaible (not an array). All the examples of foreach i see only show how to store it into mysql in a bad way or echo it out.
    Thanks for your help.
    PHP Code:
    <FORM METHOD="POST" ACTION="<? echo $PHP_SELF?>">
    <select name="resolutionarray[]" size="13" multiple="multiple" tabindex="6">
     <option value="All" selected="selected">All</option>
     <option value="640x480 ">640x480</option>
     <option value="800x600 ">800x600</option>
     <option value="1024x768 ">1024x768</option>
     <option value="1152x864 ">1152x864</option>
     <option value="1280x720 ">1280x720</option>
     <option value="1280x768 ">1280x768</option>
     <option value="1280x960 ">1280x960</option>
     <option value="1280x1024 ">1280x1024</option>
     <option value="1360x768 ">1360x768</option>
     <option value="1600x900 ">1600x900</option>
     <option value="1600x1024 ">1600x1024</option>
     <option value="1600x1200 ">1600x1200</option>
     </select>
    <INPUT TYPE="submit" NAME="submit" VALUE="Submit">
    </form>
    <?
    $resolutionarray 
    $HTTP_POST_VARS['resolutionarray'] ; 
    foreach(
    $resolutionarray as $resolution) {
    echo 
    "$resolution "; }
    ?>

  2. #2
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $str '';
    foreach(
    $resolutionarray as $resolution) {
        
    $str .=  $resolution


  3. #3
    SitePoint Member Dolby's Avatar
    Join Date
    Jun 2003
    Location
    Wisconsin
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow that was fast. Thank you Gaheris!

    [update] works perfect! thanks again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •