I have variables being passed to me via a Post operation.

They have names like: $data_XX
Where XX are contents of an array of known size.

ie:

$array=(12, 43, 23, 22);
$data_12 = "some content"
$data_43= "some other content"

How can i write code to access these data_XX elements if the XX parts are known only at runtime?

I hope this makes sense.

Thank you for any help
Scott

    Also, you can submit entire arrays with forms, and PHP will interpret it.

    IE:

    <input type="text" name="var[0]" value="data">
    <input type="text" name="var[1]" value="data2">

    will be treated like the following upon submission:

    $var = array("data", "data2");

    I've even used it for two dimensional arrays, and associative arrays (name="var[subvar][0]").

    This can come in handy.

      Write a Reply...