XBRL-Instance.php
public function ElementsByNamespaces( $namespaces )
	{
		if ( is_string( $namespaces ) )
			$namespaces = array_map( 'trim', explode( ",", $namespaces ) );

		if ( ! is_array( $namespaces ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );

		$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );

		$instance_namespaces = $this->instance->getInstanceNamespaces();

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( &$elements, $instance_namespaces, $namespaces ) {

			$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
				$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
				return isset( $namespaces[ strtolower( $namespace ) ] );
			} );

			if ( ! $namespaceElements ) return $carry;

			$carry[ $elementName ] = $namespaceElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
public function ElementsByNamespaces( $namespaces )
	{
		if ( is_string( $namespaces ) )
			$namespaces = array_map( 'trim', explode( ",", $namespaces ) );

		if ( ! is_array( $namespaces ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );

		$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );

		$instance_namespaces = $this->instance->getInstanceNamespaces();

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( &$elements, $instance_namespaces, $namespaces ) {

			$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
				$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
				return isset( $namespaces[ strtolower( $namespace ) ] );
			} );

			if ( ! $namespaceElements ) return $carry;

			$carry[ $elementName ] = $namespaceElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
public function ElementsByNamespaces ( $ namespaces ) { if ( is_string ( $ namespaces ) ) $ namespaces = array_map ( 'trim' , explode ( "," , $ namespaces ) ) ; if ( ! is_array ( $ namespaces ) ) throw new Exception ( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' ) ; $ namespaces = array_flip ( array_map ( 'strtolower' , $ namespaces ) ) ; $ instance_namespaces = $ this -> instance -> getInstanceNamespaces ( ) ; // In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
 $ elements = & $ this -> elements ; $ filtered = array_reduce ( array_keys ( $ this -> elements ) , function ( $ carry , $ elementName ) use ( & $ elements , $ instance_namespaces , $ namespaces ) { $ namespaceElements = array_filter ( $ elements [ $ elementName ] , function ( $ entry ) use ( & $ elements , $ instance_namespaces , $ namespaces ) { $ namespace = isset ( $ instance_namespaces [ $ entry [ 'namespace' ] ] ) ? $ instance_namespaces [ $ entry [ 'namespace' ] ] : $ entry [ 'namespace' ] ; return isset ( $ namespaces [ strtolower ( $ namespace ) ] ) ; } ) ; if ( ! $ namespaceElements ) return $ carry ; $ carry [ $ elementName ] = $ namespaceElements ; return $ carry ; } , array ( ) ) ; return new InstanceElementsFilter ( $ this -> instance , $ filtered ) ; }
Return a list of elements based on a set of namespaces
@param array|string $namespaces The parameter can be the name of an namespace, a comma delimited list of namespaces or an array of namespaces
@throws Exception
@return InstanceElementsFilter
Return a list of elements based on a set of namespaces