Jump to content

need to extract certain values from array


AikenDrum

Recommended Posts

Hi There,

 

relatively new to php so please bear with me -

 

When I post some data to the second page - I get the following output form $_POST:

 

Array

(

    [market] => 44

    [question568] => 2

    [question572] => 1

    [question569] => 5

 

)

 

I need to be able to parse only the questions (no idea how questions many in advance) and create a string like this :

 

568=2&572=1&569=5

 

Amy help would be greatly appreciated

 

Many kind thanks in advance

 

AikenD

Hi there -

 

many thanks for the very fast response -

 

this code returns a 0

 

$out = '';
foreach ($_POST as $k => $v) {
    if (substr($k,7) == 'question') {
        $out .= "$k=$v&";
    }
}
$out = substr(0,-1);
echo $out;

 

I changed the 7 to 8 but that did not make a difference either ?

 

Kindest

 

Aiken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.