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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.