Could also be done something like

$trace = str_replace(array(
		WWW_ROOT,
		CAKE,
		APP,
		ROOT,
		realpath(WEBROOT_DIR)
	), array(
		'WWW_ROOT/',
		'CAKE/',
		'APP/',
		'ROOT/',
		'WEBROOT_DIR/'
	), $trace);