string replacing an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

string replacing an array

Post by GeXus »

I'm using a multidimensional array for looping through a result set.

Code: Select all

while ($row = $db->fetch_array())
{
	
	$result[] = $row;
	
}
I need to apply some formating to specific columns... how would I do this?

For example, I am able to do the following

Code: Select all

$result[1][start_dt] = $result[1][start_dt] . ' added text';
This works, however with error reporting on, it says "Use of undefined constant start_dt - assumed 'start_dt' "

So i'm assuming this is not the correct way to do this....
[/quote]
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

you need to enclose start_dt within quotes:

Code: Select all

$result[1]['start_dt'] = $result[1]['start_dt'] . ' added text';
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Ah.. ha, thanks a lot!
Post Reply