Advertisements

extract_from_markers

Definition:
function extract_from_markers( $filename, $marker ) {}

Parameters

  • unknown_type $filename
  • unknown_type $marker

Return values

returns:An array of strings from a file (.htaccess ) from between BEGIN and END markers.

Source code

function extract_from_markers( $filename, $marker ) {

	$result = array ();



	if (!file_exists( $filename ) ) {

		return $result;

	}



	if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));

	{

		$state = false;

		foreach ( $markerdata as $markerline ) {

			if (strpos($markerline, '# END ' . $marker) !== false)

				$state = false;

			if ( $state )

				$result[] = $markerline;

			if (strpos($markerline, '# BEGIN ' . $marker) !== false)

				$state = true;

		}

	}



	return $result;

}

1046

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: