mattm1712 Posted October 5, 2012 Share Posted October 5, 2012 $explode = explode(" ", $occurrence->Description); $score = $explode[sizeof($explodename)]; echo $score; why would this not work i am trying to eacho the last part of the string? cheers matt Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 (edited) Because arrays start at 0, so the size of an array is 1 more than the last key. (assuming normally incremented keys like in this example, an assoc array is a whole other ballpark.) array_pop Edited October 5, 2012 by Jessica Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 5, 2012 Share Posted October 5, 2012 While I agree with Jessica's response as to why it doesn't work and how you can make it work with array_pop(), there is no reason to explode the string into an array. You can accomplish this with a simple string function: strrchr() This function returns the portion of haystack which starts at the last occurrence of needle and goes until the end of haystack. echo strrchr($occurrence->Description, ' '); 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.