Reputation: 77
i have a php if that is returning me a error, this error: Parse error: syntax error, unexpected '=', on line that that contains this code: $result -= 'tm_year' = 1900;
someone knows how to fix that ?
if (!function_exists( 'strptime' )) {
function strptime($strdate, $format) {
$plop = array( 's' => 'tm_sec', 'i' => 'tm_min', 'H' => 'tm_hour', 'd' => 'tm_mday', 'm' => 'tm_mon', 'Y' => 'tm_year' );
$regexp = preg_quote( $format, '/' );
$regexp = str_replace( array( '%d', '%m', '%Y', '%H', '%i', '%s' ), array( '(\d{2})', '(\d{2})', '(\d{4})', '(\d{2})', '(\d{2})', '(\d{2})' ), $regexp );
if (preg_match( '/^' . $regexp . '$/', $strdate, $m )) {
$result = array( 'tm_sec' => 0, 'tm_min' => 0, 'tm_hour' => 0, 'tm_mday' => 0, 'tm_mon' => 0, 'tm_year' => 0, 'tm_wday' => 0, 'tm_yday' => 0, 'unparsed' => '' );
preg_match_all( '/%(\w)/', $format, $patt );
foreach ($patt[1] as $k => $v) {
if (!isset( $plop[$v] )) {
continue;
}
$result[$plop[$v]] = intval( $m[$k + 1] );
if ($plop[$v] == 'tm_mon') {
$result -= $plop[$v] = 1;
continue;
}
}
$result -= 'tm_year' = 1900;
return $result;
}
return false;
}
}
Upvotes: 1
Views: 54
Reputation: 71384
'tm_year' is a string that you are trying to assign a value of 1900 to. You can't do that, thus the error. Seems like a case of trying to be too cute with writing shorthand code, as one honestly can't tell what your intent is here.
Upvotes: 2