SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    For $_REQUEST Problem

    Hi guys,

    I have a load of fc variables passing through from a form but the numbers are not always guaranteed to be the same, how can i build a loop of all the "fc" $_REQUEST variables?

    Eg:
    [default] => 0
    [fc15] => 0
    [fc7] => 0
    [fc12] => 0
    [fc17] => 500
    [fc2] => 175
    [other1] => 0
    [other2] => 0

    I hope that makes sense,
    Thanks,
    Dave.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    $_REQUEST['default'] = ;
    $_REQUEST['fc15'] = 0;
    $_REQUEST['fc17'] = 500;
    $_REQUEST['fc2'] = 175;
    $_REQUEST['other1'] = 0;
     

    foreach( 
    $_REQUEST as $k=>$v ){

    if( 
    substr$k) === "fc" ){

    echo 
    $k ' = ' $v ' <br>' ;

    }


    gives:

    fc15 = 0
    fc17 = 500
    fc2 = 175

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool man I though that sub string might be involved but didn't have a clue how.
    Thanks so much ill give that a whirl, looks like exacty what i'm after!!!


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
  •