Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: Replace punctuation in an associative array Date: Fri, 3 Mar 2023 08:14:22 +0100 Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net gsRnA6CSakLENjzXk4vyOALExdG9l/SotmdAfqfr+W1MtfOQIR Cancel-Lock: sha1:rk/3DjeLQue4RLK6bpfp0PrAeyE= Content-Language: de-DE In-Reply-To: Xref: csiph.com comp.lang.php:19360 The Doctor, 2023-03-02 13:44: > I wish to replace [[ with [ > > AND > > ]] with ] in an associative array . > > How can I do this? What do you mean with "in an associative array"? The values? The keys? If you want to replace the characters in values: '[[something 1', 'value 2' => 'something 2]]', ]; // Output array as it was before print_r($array); foreach($array as $key => $value) { $array[$key] = str_replace( [ '[[', ']]' ], [ '[', ']' ], $value ); } // Output as it was afterwards print_r($array); -- Arno Welzel https://arnowelzel.de