Last letters remove form array in foreach loop
Last letters remove form array in foreach loop I want to remove the last few letters from an array in a for-each loop. I am trying to show bl_date without /2018 . Now its showing 07/10/2018 & 06/30/2018 . How can echo like this 07/10 & 06/30 ? bl_date /2018 07/10/2018 & 06/30/2018 07/10 & 06/30 Array Array ( [0] => stdClass Object ( [id] => 18 [bl_user] => 61 [bl_date] => 07/10/2018 ) [1] => stdClass Object ( [id] => 17 [bl_user] => 61 [bl_date] => 06/30/2018 ) ) PHP $resultstr = array(); foreach ($billings as $billing) { $resultstr = $billing->bl_date; } echo implode(" & ",$resultstr); 2 Answers 2 One option is to use substr() to remove the last 5 characters of the string substr() Like: $resultstr = array(); foreach ($billings a...