PasteFS logoPasteFS
guest on 25 Jun, 2019
Raw Data
  1. removing an array element using foreach i.e. when we don't know what the index of that element is
  2. for example we have an array
  3. $arr = [ 'what', 1, 'hundred', 'thousand', 45, 26 ];
  4. and we want to remove 'hundred' then
  5. foreach( $arr as $key => $value ) {
  6.    if( $value == 'hundred' ) {
  7.       unset( $arr[ $key ] );
  8.    }
  9. }
  10. that's it!