Re: Retrieve Content from URL

From: Date: Fri, 02 Jun 2006 06:54:46 +0000
Subject: Re: Retrieve Content from URL
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-237249@lists.php.net to get a copy of this message
Ministério Público wrote:
Here it goes: in a certain page there is a dinamicaly generated Option ( one of those boxes from wich you can select a certain thing in a list) I want to retrieve the content of these options and the values assigned to each of them.
So if you have: <option value="test1">Test 1</option> <option value="test2">Test 2</option> You want: $test1 = "Test 1"; $test2 = "Test 2"; ?? preg_match_all('%<option value=["\']*([^"\'>]+?)["\']*\s*>(.*)</option>%isU', $text, $matches); That will give you an array that looks like this: Array (
    [0] => Array
        (
            [0] => <option value="test1">Test 1</option>
            [1] => <option value="test2">Test 2</option>
        )
    [1] => Array
        (
            [0] => test1
            [1] => test2
        )
    [2] => Array
        (
            [0] => Test 1
            [1] => Test 2
        )
) From there you should be able to work out what to do.. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#237249) next »