sea_1987 sea_1987 - 3 months ago 15
PHP Question

selecting an array key based on partial string

I have an array and in that array I have an array key that looks like,

this array key may change a little, so sometimes the page may load and the array key maybe
, I want to now is possible to just string match the array key up until the last
so that I can check what the value is after the last underscore?


one solution i can think of:

foreach($myarray as $key=>$value){
  if("show_me_" == substr($key,0,8)){
    $number = substr($key,strrpos($key,'_'));
    // do whatever you need to with $number...