php - checking if an string array raw is last one -


do know how check if string raw last 1 tried using end(...) i'm stuck how check if string array raw last 1 on array example

$array = array('raw1' => 'value1', 'raw2' => 'value2', 'raw3' => 'value3'); for($array $key => $value) {    if(strcmp(end($array), $key) == false) { // code excuted when check returns true  }  } 

iamn't sure if example correct please me checking if array raw last 1 ?? please

you can use end()

$array = array('raw1' => 'value1', 'raw2' => 'value2', 'raw3' => 'value3'); $lastelement = end($array); foreach($array $k => $v) {     if($v == $lastelement) {         // code executed last element of array       } } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -