<?php
$Is_B = 0;
$Is_I = 0;
$Anz_B = substr_count($var, "<strong>");
$Anz_I = substr_count($var, "<em>");

while ($Anz_B + $Anz_I > 0)
{
	$i++;
	if ($i > 100)
	{
		return (0);
	}
	$Anfang_B = strpos($var, "<strong>");
	$Anfang_I = strpos($var, "<em>");
	$Ende_B = strpos($var, "</strong>");
	$Ende_I = strpos($var, "</em>");
	if ($Is_B AND $Is_I)
	{
		$pdf->SetFont('Helvetica', 'BI', 10);
		if ($Ende_B < $Ende_I)
		{
			$Is_B = 0;
			$pdf->Write(4, substr($var, 0, $Ende_B));
			$var = substr($var, $Ende_B + 9);
			$Anz_B--;
		}
		else
		{
			$Is_I = 0;
			$pdf->Write(4, substr($var, 0, $Ende_I));
			$var = substr($var, $Ende_I + 5);
			$Anz_I--;
		}
	}
	elseif ($Is_B)
	{
		$pdf->SetFont('Helvetica', 'B', 10);
		if (0 == $Anfang_I AND 0 == $Ende_I)
		{
			$Is_B = 0;
			$pdf->Write(4, substr($var, 0, $Ende_B));
			$var = substr($var, $Ende_B + 9);
			$Anz_B--;
		}
		elseif ($Ende_B > $Anfang_I)
		{
			$Is_I = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_I));
			$var = substr($var, $Anfang_I + 4);
		}
		else
		{
			$Is_B = 0;
			$pdf->Write(4, substr($var, 0, $Ende_B));
			$var = substr($var, $Ende_B + 9);
			$Anz_B--;
		}
	}
	elseif ($Is_I)
	{
		$pdf->SetFont('Helvetica', 'I', 10);
		if (0 == $Anfang_B AND 0 == $Ende_B)
		{
			$Is_I = 0;
			$pdf->Write(4, substr($var, 0, $Ende_I));
			$var = substr($var, $Ende_I + 5);
			$Anz_I--;
		}
		elseif ($Ende_I > $Anfang_B)
		{
			$Is_B = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_B));
			$var = substr($var, $Anfang_B + 8);
		}
		else
		{
			$Is_I = 0;
			$pdf->Write(4, substr($var, 0, $Ende_I));
			$var = substr($var, $Ende_I + 5);
			$Anz_I--;
		}
	}
	else
	{
		$pdf->SetFont('Helvetica', '', 10);
		if (($Anfang_B <= $Anfang_I) AND ('' != $Ende_B))
		{
			$Is_B = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_B));
			$var = substr($var, $Anfang_B + 8);
		}
		elseif (($Anfang_I <= $Anfang_B) AND ('' != $Ende_I))
		{
			$Is_I = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_I));
			$var = substr($var, $Anfang_I + 4);
		}
		elseif ($Anfang_B < $Anfang_I)
		{
			$Is_I = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_I));
			$var = substr($var, $Anfang_I + 4);
		}
		elseif ($Anfang_I < $Anfang_B)
		{
			$Is_B = 1;
			$pdf->Write(4, substr($var, 0, $Anfang_B));
			$var = substr($var, $Anfang_B + 8);
		}
		else
		{
			$Anz_B--;
		}
	}
}