Reply to Re: beginner question on multidimensional arrays

Your name:

Reply:


Posted by Chung Leong on 01/31/06 01:40

matthewburton@gmail.com wrote:
> Hi everyone,
>
> I'm trying to write a program that will search a body of text and
> replace certain words (say, A, B, and C) with different words that I
> think are more appropriate (A1, B1 and C1). I have a feeling that I
> need to do this through a multidimensional array. Am I on the right
> track?
>
> thanks,
> matt

I don't really see a need for multidimensional arrays here. A single
associative array would serve perfectly well. For example, the
following is the simplest way to do what you described:

$table = array("A" => "A1", "B" => "B1", "C" => "C1");
$text = strtr($text, $table);

For something requiring more sophisticated handling, you might want to
use preg_replace(), passing twos arrays as parameters.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация