function search_text($full_text, $words, $offset=0)
$words_found = 0;
$stripped_text = remove_irrelevant_text($full_text);
$words = explode(' ', $words);
$total_words = sizeof($words);
foreach($words as $word)
if(stripos($stripped_text, $word, $offset))
$relative = ($words_found / $total_words) * 100;
$result = array(
$remove = array(
'?','!', ',', '\'', '"', '#', '$', '&', '*', '(', ')', '-', '+', '.',
'for', 'to', 'in', 'the', 'and', 'on', 'of', 'by', 'he', 'she', 'his', 'her', 'a', 'but',
'para', 'no', 'na', 'e', 'em', 'do', 'de', 'da', 'por', 'ele', 'ela', 'seu', 'dela', 'é', 'mas'
return stri_replace($remove, '', $text);
$str = <<<EOT
Albert's Einstein was born in Ulm, in the Kingdom of Württemberg in the German Empire on 14 March 1879. His father was Hermann Einstein, a salesman and engineer. His mother was Pauline Einstein (née Koch). In 1880, the family moved to Munich, where his father and his uncle founded Elektrotechnische Fabrik J. Einstein & Cie, a company that manufactured electrical equipment based on direct current.
The Einsteins were non-observant Ashkenazi Jews. Albert's attended a Catholic elementary school from the age of five for three years. At the age of eight, he was transferred to the Luitpold Gymnasium (now known as the Albert's Einstein Gymnasium), where he received advanced primary and secondary school education until he left Germany seven years later. Contrary to popular suggestions that he had struggled with early speech difficulties, the Albert's Einstein Archives indicate he excelled at the first school that he attended. He was right-handed; there appears to be no evidence for the widespread popular belief that he was left-handed.
His father once showed him a pocket compass; Einstein realized that there must be something causing the needle to move, despite the apparent "empty space". As he grew, Einstein built models and mechanical devices for fun and began to show a talent for mathematics. When Einstein was ten years old, Max Talmud (later changed to Max Talmey), a poor Jewish medical student from Poland, was introduced to the Einstein family by his brother. During weekly visits over the next five years, he gave the boy popular books on science, mathematical texts and philosophical writings. These included Immanuel Kant's Critique of Pure Reason, and Euclid's Elements (which Einstein called the "holy little geometry book").[fn 1]
In 1894, his father's company failed: direct current (DC) lost the War of Currents to alternating current (AC). In search of business, the Einstein family moved to Italy, first to Milan and then, a few months later, to Pavia. When the family moved to Pavia, Einstein stayed in Munich to finish his studies at the Luitpold Gymnasium. His father intended for him to pursue electrical engineering, but Einstein clashed with authorities and resented the school's regimen and teaching method. He later wrote that the spirit of learning and creative thought were lost in strict rote learning. At the end of December 1894, he travelled to Italy to join his family in Pavia, convincing the school to let him go by using a doctor's note. It was during his time in Italy that he wrote a short essay with the title "On the Investigation of the State of the Ether in a Magnetic Field."
In 1895, at the age of sixteen, Einstein sat the entrance examinations for the Swiss Federal Polytechnic in Zürich (later the Eidgenössische Technische Hochschule ETH). He failed to reach the required standard in the general part of the examination, but obtained exceptional grades in physics and mathematics. On the advice of the Principal of the Polytechnic, he attended the Argovian cantonal school (gymnasium) in Aarau, Switzerland, in 1895–96 to complete his secondary schooling. While lodging with the family of Professor Jost Winteler, he fell in love with Winteler's daughter, Marie. (Albert's sister Maja later married Wintelers' son Paul.) In January 1896, with his father's approval, he renounced his citizenship in the German Kingdom of Württemberg to avoid military service. In September 1896, he passed the Swiss Matura with mostly good grades, including a top grade of 6 in physics and mathematical subjects, on a scale of 1-6, and, though only seventeen, enrolled in the four-year mathematics and physics teaching diploma program at the Zürich Polytechnic. Marie Winteler moved to Olsberg, Switzerland for a teaching post.
Einstein's future wife, Mileva Marić, also enrolled at the Polytechnic that same year, the only woman among the six students in the mathematics and physics section of the teaching diploma course. Over the next few years, Einstein and Marić's friendship developed into romance, and they read books together on extra-curricular physics in which Einstein was taking an increasing interest. In 1900, Einstein was awarded the Zürich Polytechnic teaching diploma, but Marić failed the examination with a poor grade in the mathematics component, theory of functions. There have been claims that Marić collaborated with Einstein on his celebrated 1905 papers, but historians of physics who have studied the issue find no evidence that she made any substantive contributions xdva's uter.
$search = "where did Einstein's wife was born?";
$result = search_text($str, $search);
if($result['percentage_found'] > 50)
echo $result['percentage_found']. '% related to your query (Total words: '.$result['total_words'].', Words found: '.$result['percentage_found'].')';
echo 'Could not find anything related';