[PHP] Alle items in $_POST veranderen

Pagina: 1
Acties:
  • 38 views sinds 30-01-2008

  • Guillome
  • Registratie: Januari 2001
  • Niet online
Hi,

Ik heb een formulier gemaakt. En van alle ingetikte waardes moeten de ' en " vervangen worden door `.
Ik wou dat doen dmv alle items in $_POST langs te lopen met een preg_repace, maar hoe kan ik al die items doorlopen?

forEach doet niet wat ik wil, dan kan ik de waardes uitlezen, maar niet veranderen.
Kan iemand mij helpen?

Bij voorbaat dank

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


  • stekkel
  • Registratie: Augustus 2001
  • Laatst online: 23-04 13:07
PHP:
1
2
3
foreach($_POST as $k => $v) {
    $_POST[$k] = str_replace(array('"',"'"),array('`','`'),$v);
}

  • Guillome
  • Registratie: Januari 2001
  • Niet online
cool dank je :) Snel beantwoord! Super

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


  • LuCarD
  • Registratie: Januari 2000
  • Niet online

LuCarD

Certified BUFH

Niet getest maar dit zou ook moeten werken
PHP:
1
$_POST = str_replace(array('"',"'"),array('`','`'), $_POST);


http://nl2.php.net/str_replace
mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count])

<SNIP>

If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.

If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string; then this replacement string is used for every value of search.

Programmer - an organism that turns coffee into software.


  • Guillome
  • Registratie: Januari 2001
  • Niet online
Die werkt ook :o die is nog korter :D Dank je!

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

lastig, die manual :Y)

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


  • Skaah
  • Registratie: Juni 2001
  • Niet online
Je zou ook array_walk() kunnen gebruiken.

  • Bosmonster
  • Registratie: Juni 2001
  • Laatst online: 10-05 18:53

Bosmonster

*zucht*

of array_map

[ Voor 22% gewijzigd door Bosmonster op 18-06-2004 16:36 ]


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

drm vergat wat ijzerwerk hierbij :+

Professionele website nodig?

Pagina: 1

Dit topic is gesloten.