Append value to existing array key

    Date: 02/26/08 (PHP Community)    Keywords: database

    I'm trying to create an array that holds the name of the table as its key, and the field as its value. The array is populated via database output. However, the same table may be listed multiple times, since more than 1 field for each table can be present.

    However, I am having trouble appending a field to the previously created key/value pair.

    $search_array = array();
    $current_table = '';
    $result = $d->dbQuery('SELECT the_table, the_fields FROM sitesearch ORDER BY id');
    while($row = $d->dbFetchObject($result)):
    	if ($current_array != $row->the_table):
    		$search_array[$row->the_table] = $row->the_fields;
    		$current_table = $row->the_table;
    	else:
    		$search_array[${$row->the_table}] .= ','.$row->the_fields;
    	endif;
    endwhile;
    

    Source: http://community.livejournal.com/php/615163.html

« The Future Of Social... || Code Generators »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home