Jump to content

[SOLVED] extracting one single variable from an array by key


discostudio

Recommended Posts


$link = "http://www.google.com/base/feeds/snippets/1029346123708061275";

$temp = explode("/", $link);

---
[temp] => Array
                (
                    [0] => http:
                    [1] => 
                    [2] => www.google.com
                    [3] => base
                    [4] => feeds
                    [5] => snippets
                    [6] => 5790055782500671666
                )
---
$froogleid = extract($temp, EXTR_PREFIX_SAME, "6");

echo $froogleid;

 

OK, so I am trying to extract the value from the array key "6", I can't work this out! - I can't even find a predefined-function to do this.

 

I just want it to output the value of key 6.

 

Please help me people!

Ahh, yes!

 

I should have mentioned that I am trying to extract the last variable from the array, that was just an example, but depending on the url, they arrey could have any number of parts.

 

I am really looking for a one-line solution with something like "list" but I can't seem to find one.

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.