public function serialize($val) {
		if($this->get('many')) {
			if(!$val instanceof ManyCollection)
				return serialize([]);
			$r = [];
			foreach($val as $v) {
				$s = $this->doSerialize($v);
				if($s !== null)
					$r[] = $s;
			}
			return serialize($r);
		}
		else
			return $this->doSerialize($val);
	}
public function serialize($val) {
		if($this->get('many')) {
			if(!$val instanceof ManyCollection)
				return serialize([]);
			$r = [];
			foreach($val as $v) {
				$s = $this->doSerialize($v);
				if($s !== null)
					$r[] = $s;
			}
			return serialize($r);
		}
		else
			return $this->doSerialize($val);
	}
public function serialize ( $ val ) { if ( $ this -> get ( 'many' ) ) { if ( ! $ val instanceof ManyCollection ) return serialize ( [ ] ) ; $ r = [ ] ; foreach ( $ val as $ v ) { $ s = $ this -> doSerialize ( $ v ) ; if ( $ s !== null ) $ r [ ] = $ s ; } return serialize ( $ r ) ; } else return $ this -> doSerialize ( $ val ) ; }
Serialize the value.
@param  mixed $val
@return string
Serialize the value .