I think this is what you are trying to accomplish?
$html .="<a id='test' rel="nofollow" href="https://example.com/cars/?aff="". echo get_the_title( $post_id ) ." target="_blank">";
I think this is what you are trying to accomplish?
$html .="<a id='test' rel="nofollow" href="https://example.com/cars/?aff="". echo get_the_title( $post_id ) ." target="_blank">";