Skip to content
Snippets Groups Projects
Commit 33813073 authored by Kjartan Mannes's avatar Kjartan Mannes
Browse files

- Changed field_get/set() to be more efficent.

parent 0743b2cd
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -191,34 +191,14 @@ function form_submit($value) {
}
function field_get($string, $name) {
foreach (explode(",", $string) as $data) {
$entry = explode("=", $data);
if ($entry[0] == $name) return $entry[1];
}
ereg(",$name=([^,]+)", ",$string", $regs);
return $regs[1];
}
function field_set($string, $name, $value) {
if (!$value) {
// remove entry:
foreach (explode(",", $string) as $data) {
$entry = explode("=", $data);
if ($entry[0] != $name) $rval .= "$entry[0]=$entry[1],";
}
}
else if (strstr($string, "$name=")) {
// found: update exsisting entry:
foreach (explode(",", $string) as $data) {
$entry = explode("=", $data);
if ($entry[0] == $name) $entry[1] = $value;
$rval .= "$entry[0]=$entry[1],";
}
}
else {
// not found:
$rval = "$string$name=$value,";
}
return $rval;
$rval = ereg_replace(",$name=[^,]+", "", ",$string");
if ($value) $rval .= ($rval == "," ? "" : ",") ."$name=$value";
return substr($rval, 1);
}
function field_merge($a, $b) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment