Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[PHP] Split Strings and Integers in PHP Using Regular Expressions
<?php
$totalTimeParts = array_values(
array_filter(
preg_split("/(<=[0-9])*([a-zA-Z])/i", $totalTime)
)
);
if (isset($totalTimeParts[0]) && isset($totalTimeParts[1]) && '60' === $totalTimeParts[1]) {
$hours = (int)$totalTimeParts[0] + 1;
$minutes = '00';
$totalTime = "P$hours" . 'H' . $minutes . 'M';
}
return $totalTime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.