Daten (Mehrzahl von Datum) aus einem String extrahieren

Das erinnert mich immer an meinen früheren Chef. Der sagte zum Plural von Datum, „Datümer“. 😏

	/**
	 * get_dates_from_string
	 * This function returns all occurring dates in a string in the two formats m.d.y and m.d.Y as an array
	 * @param  string $string
	 * @return array
	 */
	public static function get_dates_from_string($string){
		preg_match_all('/(\d{2}.\d{2}.\d{4})/', $string, $matches1);
		$temp = str_replace($matches1[0], '', $string);
		preg_match_all('/(\d{2}.\d{2}.\d{2})/', str_replace(',', '.', $temp), $matches2);
		$matches = array_merge($matches1[0], $matches2[0]);
		return $matches;
	}
Veröffentlicht am
Kategorisiert in php