Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
33813073
Commit
33813073
authored
Jun 24, 2001
by
Kjartan
Browse files
- Changed field_get/set() to be more efficent.
parent
0743b2cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
33813073
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment