Problem mit Array-Ausgabe

Merlin732

Erfahrenes Mitglied
Hi,

ich möchte ein Suchergebniss meiner Suche ausgeben, dazu habe ich diesen Quellcode

PHP:
// Die Datenbank ansprechen und in einer Schleife ausgeben - SUCHE NACH UEBERSCHRIFT
    $query = "SELECT * FROM tt_content WHERE bodytext LIKE '%".komponenten."%' AND hidden = 0 AND deleted = 0";
    
    $res = mysql(TYPO3_db, $query);

    while($row = mysql_fetch_array($res)) {
    
      $language_uid = $row["sys_language_uid"];
      $rootline = $GLOBALS["TSFE"]->rootLine;
    
      $header = $row["header"];
      $pid = $row["pid"];
      $bodytext = $row["bodytext"];      
      //explode teilt den string wieder an der ' ' und array_slice erstellt einen neuen array mit  
      //den ersten x elementen = worten des suchergebnisses
      $first = array_slice(explode(' ', $bodytext), 0, 25); 
      $kurzer_bodytext = join(' ', $first) . '... ';
      
      $content .='<table align="center" width="80%" class=cc_suche>
	                 <tr> 
                      <td width="6%"><img src="fileadmin/images/flag_germany.gif" width="18" height="12" hspace="3" border="0"></td>
                      <td width="94%">'.$rootline[1].'</td>
                   </tr>  
	                 <tr class=cc_suche_titel>
	                    <td width="6%"></td>
                      <td width="94%"><a href="index.php?id='.$pid.'&L='.$language_uid.'">'.$header.'</a>
                      </td>
                   </tr>
	                 <tr>
	                    <td width="6%"></td>
                      <td width="94%">'.$kurzer_bodytext.'</td>
                   </tr>
                  </table>
                  <p><p><p><p>
                 '; 
    }

	  return $content;

Es klappt auch alles einwandfrei, bis auf die Rootline, wo Sie stehen sollte erscheint nur "Array"...wie kann ich dies umgehen?
 
Also ich habe mir mit print_r(array_values($rootline)) mal die Werte ausgeben lassen und erhalte folgendes Ergebniss:
Code:
Array ( [0] => Array ( [pid] => 476 [uid] => 478 [t3ver_oid] => 0 [title] => CC-Search [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 2 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) [1] => Array ( [pid] => 421 [uid] => 476 [t3ver_oid] => 0 [title] => Tests [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 1 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) [2] => Array ( [pid] => 0 [uid] => 421 [t3ver_oid] => 0 [title] => root [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 4 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) ) Array ( [0] => Array ( [pid] => 476 [uid] => 478 [t3ver_oid] => 0 [title] => CC-Search [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 2 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) [1] => Array ( [pid] => 421 [uid] => 476 [t3ver_oid] => 0 [title] => Tests [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 1 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) [2] => Array ( [pid] => 0 [uid] => 421 [t3ver_oid] => 0 [title] => root [alias] => [nav_title] => [media] => [layout] => 0 [hidden] => 0 [starttime] => 0 [endtime] => 0 [fe_group] => 0 [extendToSubpages] => 0 [doktype] => 4 [TSconfig] => [storage_pid] => 0 [is_siteroot] => 0 [mount_pid] => 0 [mount_pid_ol] => 0 [fe_login_mode] => 0 ) )
 
Die Frage ist nun, welchen Wert du als „rootline“ erwartest? Denn wie die detaillierte Schreibweise der $TSFE->rootLine-Variable beweißt, ist das Element mit dem numerischen Schlüssel „1“ definitiv ein Array.
 
Zurück