Code: Select all
<span id="Stats_lbl1">5 days 12 hours 4 minutes</span>Code: Select all
<?php
$content = '<span id="Stats_lbl1">5 days 12 hours 4 minutes</span>';
preg_match('#(?<=<span id="Stats_lbl1">).*?(?=</span>)#', $content, $stats);
?>Code: Select all
preg_match('#(?<=<span id="Stats_lbl1">)(\d+)(.*?)(\d+)(.*?)(\d+)(.*?)(?=</span>)#', $content, $stats);Code: Select all
//Case 1
$content = '<span id="Stats_lbl1">x days y hours z minutes</span>';
//Case 2
$content = '<span id="Stats_lbl1">y hours z minutes</span>';
//Case 3
$content = '<span id="Stats_lbl1">z minutes</span>';Case One should end up like:
$stats[0] = x;
$stats[1] = y;
$stats[2] = z;
Case Two:
$stats[0] = 0;
$stats[1] = y;
$stats[2] = z;
Case Three
$stats[0] = 0;
$stats[1] = 0;
$stats[2] = z;
That way, index 0 will always be the number of days, index 1 will be the number of hours, and index 2 will be the number of minutes. If course that is the ideal situation I'd like, but I wouldn't mind checking the size of the array [if 3 => case 1,;if 2 => case 2; if 1 => case 3]
Thanks