public function reverse_left_and_right_background_position($value) {
		// multiple background case
		if (strpos($value, ',') !== false) {
			$values = $this->explode_ws(',', $value);
			if (count($values) > 1) {
				foreach ($values as $k=>$v) {
					$values[$k] = $this->reverse_left_and_right_background_position($v);
				}
				return implode(',', $values);
			}
		}

		// if no explicit left or right value
		if (stripos($value, 'left') === false and stripos($value, 'right') === false) {
			$values = $this->explode_ws(' ', trim($value));
			$values = array_map('trim', $values);
			$values = array_filter($values);
			$values = array_values($values);
			if (count($values) == 1) {
				return "left $value";
			}
			if ($values[1] == 'top' or $values[1] == 'bottom') {
				return 'left ' . implode(' ', $values);
			}
			else {
				$last = array_pop($values);
				return implode(' ', $values) . ' left ' . $last;
			}
		}

		return $value;
	}
public function reverse_left_and_right_background_position($value) {
		// multiple background case
		if (strpos($value, ',') !== false) {
			$values = $this->explode_ws(',', $value);
			if (count($values) > 1) {
				foreach ($values as $k=>$v) {
					$values[$k] = $this->reverse_left_and_right_background_position($v);
				}
				return implode(',', $values);
			}
		}

		// if no explicit left or right value
		if (stripos($value, 'left') === false and stripos($value, 'right') === false) {
			$values = $this->explode_ws(' ', trim($value));
			$values = array_map('trim', $values);
			$values = array_filter($values);
			$values = array_values($values);
			if (count($values) == 1) {
				return "left $value";
			}
			if ($values[1] == 'top' or $values[1] == 'bottom') {
				return 'left ' . implode(' ', $values);
			}
			else {
				$last = array_pop($values);
				return implode(' ', $values) . ' left ' . $last;
			}
		}

		return $value;
	}
public function reverse_left_and_right_background_position ( $ value ) { // multiple background case if ( strpos ( $ value , ',' ) !== false ) { $ values = $ this -> explode_ws ( ',' , $ value ) ; if ( count ( $ values ) > 1 ) { foreach ( $ values as $ k => $ v ) { $ values [ $ k ] = $ this -> reverse_left_and_right_background_position ( $ v ) ; } return implode ( ',' , $ values ) ; } } // if no explicit left or right value if ( stripos ( $ value , 'left' ) === false and stripos ( $ value , 'right' ) === false ) { $ values = $ this -> explode_ws ( ' ' , trim ( $ value ) ) ; $ values = array_map ( 'trim' , $ values ) ; $ values = array_filter ( $ values ) ; $ values = array_values ( $ values ) ; if ( count ( $ values ) == 1 ) { return "left $value" ; } if ( $ values [ 1 ] == 'top' or $ values [ 1 ] == 'bottom' ) { return 'left ' . implode ( ' ' , $ values ) ; } else { $ last = array_pop ( $ values ) ; return implode ( ' ' , $ values ) . ' left ' . $ last ; } } return $ value ; }
Reversing background position shorthands
@param string $value
@return string
Reversing background position shorthands