PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $values = [ '123', '10/11/2023', 'dfgdfg', ]; foreach ($values as $value) { if (is_numeric($value)) { echo "Numeric value: $value\n"; } else { try { $date = Carbon::createFromFormat('d/m/Y', $value); echo "Valid date: {$date->format('d/m/Y')}\n"; } catch(\Throwable $e) { echo "Invalid date:{$e->getMessage()}\n"; } } }
Show:  
Copy Clear