Explode-update-implode not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At least not the way I expected it to. Apparently I am doing something
wrong, but I can't find anything specific that explains it. This is in
PHP 5.2.6.

Here is the sequence I am trying to implement without the database
portion. (This is typed in since the VNC I am using doesn't support
pasting from a Linux client to a MS-Windows server.)

-------------------------------------
$buff = "key1|value1~key2|value2";

$lines = explode ("~", $buff);

foreach ($lines as $kvpair) {
   $line = explode ("|", $kvpair);
   if ($line[0] == "key1") {
      $line[1] = "value3";
      $kvpair = implode ("|", $line);
      break;
   }
}
$newbuff = implode ("~", $lines);
-------------------------------------

$kvpair is modified, but that change is ignored by implode() with
$newbuff still containing "key1|value1".

So why doesn't the change to $kvpair get brought in by implode? What
should I do to update that value?

Bob McConnell

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux