discostudio Posted July 16, 2007 Share Posted July 16, 2007 $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! Quote Link to comment Share on other sites More sharing options...
lur Posted July 16, 2007 Share Posted July 16, 2007 $froogleid = $temp[6]; ? Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 16, 2007 Share Posted July 16, 2007 echo $temp[6]; Quote Link to comment Share on other sites More sharing options...
discostudio Posted July 16, 2007 Author Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
discostudio Posted July 16, 2007 Author Share Posted July 16, 2007 I've tried all-sorts, even reversing the array etc. No joy as yet.... Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted July 16, 2007 Share Posted July 16, 2007 $count = count($temp) - 1; echo $temp[$count]; should work I believe Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted July 16, 2007 Share Posted July 16, 2007 I think you should read up on arrays before continuing with what you're doing. You're missing a very fundamental idea here. Quote Link to comment Share on other sites More sharing options...
discostudio Posted July 16, 2007 Author Share Posted July 16, 2007 done it! this is how you echo the last value in any array: echo end($engineIdArray); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.