How to remove the two duplicate values

How to remove the two duplicate values

Example I have the variable 1 $help_brother:

$help_brother = '30,45,12,13,14,15';

And the variable 2 Force World:

$force_world = '45,12,15';

The result must be:

Result: '30,13,14';

Any help is welcome. Thanks in advance.

Topic php Wordpress

Category Web


Here is the result

$help_brother = '30,45,12,13,14,15';
$force_world = '45,12,15';

$help_brother_array = explode(',', $help_brother);
$force_world_array = explode(',', $force_world);


$Result = array_diff($help_brother_array, $force_world_array);
echo implode(",",$Result);

You can get the following result.

If it helps then upvode the answer.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.