src/CssManager.php
function _nthchild($f, $c)
	{
		// $f is formula e.g. 2N+1 split into a preg_match array
		// $c is the comparator value e.g row or column number
		$c += 1;
		$select = false;

		$f_count = count($f);
		if ($f[0] === 'ODD') {
			$a = 2;
			$b = 1;
		} elseif ($f[0] === 'EVEN') {
			$a = 2;
			$b = 0;
		} elseif ($f_count === 2) {
			$a = 0;
			$b = $f[1] + 0;
		} // e.g. (+6)
		elseif ($f_count === 3) {  // e.g. (2N)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = 0;
		} elseif ($f_count === 4) {  // e.g. (2N+6)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = $f[3] + 0;
		} else {
			return false;
		}
		if ($a > 0) {
			if (((($c % $a) - $b) % $a) === 0 && $c >= $b) {
				$select = true;
			}
		} elseif ($a == 0) {
			if ($c == $b) {
				$select = true;
			}
		} else {  // if ($a<0)
			if (((($c % $a) - $b) % $a) === 0 && $c <= $b) {
				$select = true;
			}
		}
		return $select;
	}
function _nthchild($f, $c)
	{
		// $f is formula e.g. 2N+1 split into a preg_match array
		// $c is the comparator value e.g row or column number
		$c += 1;
		$select = false;

		$f_count = count($f);
		if ($f[0] === 'ODD') {
			$a = 2;
			$b = 1;
		} elseif ($f[0] === 'EVEN') {
			$a = 2;
			$b = 0;
		} elseif ($f_count === 2) {
			$a = 0;
			$b = $f[1] + 0;
		} // e.g. (+6)
		elseif ($f_count === 3) {  // e.g. (2N)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = 0;
		} elseif ($f_count === 4) {  // e.g. (2N+6)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = $f[3] + 0;
		} else {
			return false;
		}
		if ($a > 0) {
			if (((($c % $a) - $b) % $a) === 0 && $c >= $b) {
				$select = true;
			}
		} elseif ($a == 0) {
			if ($c == $b) {
				$select = true;
			}
		} else {  // if ($a<0)
			if (((($c % $a) - $b) % $a) === 0 && $c <= $b) {
				$select = true;
			}
		}
		return $select;
	}
function _nthchild ( $ f , $ c ) { // $f is formula e.g. 2N+1 split into a preg_match array // $c is the comparator value e.g row or column number $ c += 1 ; $ select = false ; $ f_count = count ( $ f ) ; if ( $ f [ 0 ] === 'ODD' ) { $ a = 2 ; $ b = 1 ; } elseif ( $ f [ 0 ] === 'EVEN' ) { $ a = 2 ; $ b = 0 ; } elseif ( $ f_count === 2 ) { $ a = 0 ; $ b = $ f [ 1 ] + 0 ; } // e.g. (+6) elseif ( $ f_count === 3 ) { // e.g. (2N) if ( $ f [ 2 ] == '' ) { $ a = 1 ; } elseif ( $ f [ 2 ] == '-' ) { $ a = - 1 ; } else { $ a = $ f [ 2 ] + 0 ; } $ b = 0 ; } elseif ( $ f_count === 4 ) { // e.g. (2N+6) if ( $ f [ 2 ] == '' ) { $ a = 1 ; } elseif ( $ f [ 2 ] == '-' ) { $ a = - 1 ; } else { $ a = $ f [ 2 ] + 0 ; } $ b = $ f [ 3 ] + 0 ; } else { return false ; } if ( $ a > 0 ) { if ( ( ( ( $ c % $ a ) - $ b ) % $ a ) === 0 && $ c >= $ b ) { $ select = true ; } } elseif ( $ a == 0 ) { if ( $ c == $ b ) { $ select = true ; } } else { // if ($a<0) if ( ( ( ( $ c % $ a ) - $ b ) % $ a ) === 0 && $ c <= $ b ) { $ select = true ; } } return $ select ; }
mPDF 5.7.4   nth-child
mPDF 5 . 7 . 4 nth - child