I want to use php str_replace() function on some condition.
Eg : if the string has am i want to replace with :00 and if it has pm i want to replace with :00. There will be one am or pm on the string and I want to replace with same variable. How do I do it using PHP?
$classRoom->start =Carbon::parse($request->input('start'));
dd(str_replace(array('am', ':00'), array('pm', ':00'),$request->input('start')));
str_replace(array('am', 'pm'), ':00', $request->input('start'));
You can pass an array to both of the first parameters for str_replace. You need to pass an array of the text to search for. Then you pass an array or string of things to replace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With