<?php include "astrstr.php"; $needles = array( 'apple', 'banana', 'pear', 'orange', ); $haystack = 'The fruiterer has some bananas and apples today. Unfortunately, there are no oranges, but the pears will be in tomorrow.'; // this will return the string from the first instance of 'banana' // the first needle in the haystack echo astrstr($haystack, $needles) . "\r\n"; // this will return the string upto the first instance of 'banana' // the first needle in the haystack echo astrstr($haystack, $needles, 0, ASTR_BEFORE_NEEDLE) . "\r\n"; // this will return the string from the first instance of 'apple' // the first needle in the array of needles echo astrstr($haystack, $needles, 0, ASTR_NEEDLE_ORDER) . "\r\n"; // this will return the string from the first instance of 'orange' // the first needle in the haystack after the offset of 50 echo astrstr($haystack, $needles, 50) . "\r\n"; // this will return the string upto the first instance of 'orange' // the first needle in the haystack after the offset of 50 echo astrstr($haystack, $needles, 50, ASTR_BEFORE_NEEDLE) . "\r\n"; // this will return the string between the offset and the first instance of 'orange' // the first needle in the haystack after the offset of 50 echo astrstr($haystack, $needles, 50, ASTR_AFTER_OFFSET) . "\r\n"; // this will return the string from the first instance of 'pear' // the first needle in the array of needles found after the offset of 50 echo astrstr($haystack, $needles, 50, ASTR_NEEDLE_ORDER) . "\r\n"; ?>