src/Alg/SgmlTagReader.php
public static function getTagData( $string, $transformKeys = 0 )
	{
		$string		= trim( $string );
		$attributes	= array();
		$content	= "";
		$nodename	= "";

		if( preg_match( "@^<([a-z]+)@", $string, $results ) )
			$nodename	= $results[1];
		if( preg_match( "@>([^<]*)<@", $string, $results ) )
			$content	= $results[1];
		if( preg_match_all( '@ (\S+)="([^"]+)"@', $string, $results ) )
		{
			$array	= array_combine( $results[1], $results[2] );
			foreach( $array as $key => $value )
			{
				if( $transformKeys == self::TRANSFORM_LOWERCASE )
					$key	= strtolower( $key );
				else if( $transformKeys == self::TRANSFORM_UPPERCASE )
					$key	= strtoupper( $key );
				$attributes[$key]	= $value;
			}
		}
		if( preg_match_all( "@ (\S+)='([^']+)'@", $string, $results ) )
		{
			$array	= array_combine( $results[1], $results[2] );
			foreach( $array as $key => $value )
			{
				if( $transformKeys == self::TRANSFORM_LOWERCASE )
					$key	= strtolower( $key );
				else if( $transformKeys == self::TRANSFORM_UPPERCASE )
					$key	= strtoupper( $key );
				$attributes[$key]	= $value;
			}
		}
		return array(
			'nodename'		=> $nodename,
			'content'		=> $content,
			'attributes'	=> $attributes
		);
	}
public static function getTagData( $string, $transformKeys = 0 )
	{
		$string		= trim( $string );
		$attributes	= array();
		$content	= "";
		$nodename	= "";

		if( preg_match( "@^<([a-z]+)@", $string, $results ) )
			$nodename	= $results[1];
		if( preg_match( "@>([^<]*)<@", $string, $results ) )
			$content	= $results[1];
		if( preg_match_all( '@ (\S+)="([^"]+)"@', $string, $results ) )
		{
			$array	= array_combine( $results[1], $results[2] );
			foreach( $array as $key => $value )
			{
				if( $transformKeys == self::TRANSFORM_LOWERCASE )
					$key	= strtolower( $key );
				else if( $transformKeys == self::TRANSFORM_UPPERCASE )
					$key	= strtoupper( $key );
				$attributes[$key]	= $value;
			}
		}
		if( preg_match_all( "@ (\S+)='([^']+)'@", $string, $results ) )
		{
			$array	= array_combine( $results[1], $results[2] );
			foreach( $array as $key => $value )
			{
				if( $transformKeys == self::TRANSFORM_LOWERCASE )
					$key	= strtolower( $key );
				else if( $transformKeys == self::TRANSFORM_UPPERCASE )
					$key	= strtoupper( $key );
				$attributes[$key]	= $value;
			}
		}
		return array(
			'nodename'		=> $nodename,
			'content'		=> $content,
			'attributes'	=> $attributes
		);
	}
public static function getTagData ( $ string , $ transformKeys = 0 ) { $ string = trim ( $ string ) ; $ attributes = array ( ) ; $ content = "" ; $ nodename = "" ; if ( preg_match ( "@^<([a-z]+)@" , $ string , $ results ) ) $ nodename = $ results [ 1 ] ; if ( preg_match ( "@>([^<]*)<@" , $ string , $ results ) ) $ content = $ results [ 1 ] ; if ( preg_match_all ( '@ (\S+)="([^"]+)"@' , $ string , $ results ) ) { $ array = array_combine ( $ results [ 1 ] , $ results [ 2 ] ) ; foreach ( $ array as $ key => $ value ) { if ( $ transformKeys == self :: TRANSFORM_LOWERCASE ) $ key = strtolower ( $ key ) ; else if ( $ transformKeys == self :: TRANSFORM_UPPERCASE ) $ key = strtoupper ( $ key ) ; $ attributes [ $ key ] = $ value ; } } if ( preg_match_all ( "@ (\S+)='([^']+)'@" , $ string , $ results ) ) { $ array = array_combine ( $ results [ 1 ] , $ results [ 2 ] ) ; foreach ( $ array as $ key => $ value ) { if ( $ transformKeys == self :: TRANSFORM_LOWERCASE ) $ key = strtolower ( $ key ) ; else if ( $ transformKeys == self :: TRANSFORM_UPPERCASE ) $ key = strtoupper ( $ key ) ; $ attributes [ $ key ] = $ value ; } } return array ( 'nodename' => $ nodename , 'content' => $ content , 'attributes' => $ attributes ) ; }
Returns all Information from a Tag.
@access		public
@static
@param		string		$string			String containing exactly 1 SGML based Tag
@return		array
Returns all Information from a Tag .