Remove Leading Zero PHP

User
$openingdate=explode(':',$day['opening_time'])
remove leading 0 if any
Assistant
You can remove the leading zero from the extracted hour like this:

$openingdate = explode(':', $day['opening_time']);
$openingdate[0] = ltrim($openingdate[0], '0'); // Remove leading zero

print_r($openingdate);

### Explanation:
– `explode(':', $day['opening_time'])` splits the time string into an array.
– `ltrim($openingdate[0], '0')` removes any leading zero from the hour part.

#### Example:
If `$day['opening_time'] = '08:30'`,
After processing, `$openingdate` will be:

["8", "30"]

Let me know if you need any modifications! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *