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! Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/ Share on other sites More sharing options...
lur Posted July 16, 2007 Share Posted July 16, 2007 $froogleid = $temp[6]; ? Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299757 Share on other sites More sharing options...
metrostars Posted July 16, 2007 Share Posted July 16, 2007 echo $temp[6]; Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299759 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. Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299810 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.... Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299812 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 Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299813 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. Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299824 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); Link to comment https://forums.phpfreaks.com/topic/60266-solved-extracting-one-single-variable-from-an-array-by-key/#findComment-299832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.