Optimiser avec array_intersect_key #4916

Open
opened 6 days ago by JLuc · 0 comments
JLuc commented 6 days ago

Dans objet_modifier_champs (https://git.spip.net/spip/spip/src/branch/master/ecrire/inc/modifier.php#L144) il semble que la boucle

$champs = [];
foreach ($desc['field'] as $champ => $ignore) {
	if (isset($c[$champ])) {
		$champs[$champ] = $c[$champ];
	}
}

peut être plus simplement et plus efficacement écrite avec

$champs = array_intersect_key($c, $desc)
Dans `objet_modifier_champs` (https://git.spip.net/spip/spip/src/branch/master/ecrire/inc/modifier.php#L144) il semble que la boucle ``` $champs = []; foreach ($desc['field'] as $champ => $ignore) { if (isset($c[$champ])) { $champs[$champ] = $c[$champ]; } } ``` peut être plus simplement et plus efficacement écrite avec ``` $champs = array_intersect_key($c, $desc) ```
JLuc changed title from Optimiser avec to Optimiser avec array_intersect_key 6 days ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.