arrayutils
  • Home
  • 📖How to use?
    • ⚡Installation
  • 📖Methods
    • ⚡Static method
      • static from()
      • static of()
      • static mapToArray()
    • ⚡Generic method
      • join()
      • every()
      • some()
      • reduce()
        • reduceRight()
      • sum()
      • pop()
      • shift()
      • includes()
      • keyExists()
      • indexOf()
      • find()
        • findIndex()
      • first()
        • keyFirst()
      • last()
        • keyLast()
      • random()
        • keyRandom()
      • splice()
    • ⚡Chain method
      • chunk()
      • column()
      • combine()
      • concat()
        • concatSoft()
      • countValues()
      • diff()
        • diffAssoc()
        • diffKey()
      • fill()
        • fillKeys()
      • filter()
      • flat()
        • flatMap()
      • flip()
      • forEach()
      • intersect()
        • intersectAssoc()
        • intersectKey()
      • keys()
      • map()
        • mapAssoc()
        • mapKey()
      • pad()
      • push()
      • replace()
      • reverse()
      • slice()
      • sort()
        • sortKey()
      • unique()
      • unshift()
      • values()
  • 📖Suffixes
    • ⚡Suffix - From
    • ⚡Suffix - As
  • links
    • 📌Github repo
    • 📌Packagist project
    • 📌Poggit project
Powered by GitBook
On this page
  • Syntax
  • Parameter
  • Prefixing
  • References
  1. 📖Methods
  2. ⚡Chain method
  3. concat()

concatSoft()

The concatSoft() method all similar to concat(), but not overwrite existing keys

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["first" => 1, "second" => 2, "third" => 3]);

//Same key values are ignored
$arrayUtils->concat(["first" => 0, "4th" => 4]);
// expected output: ["first" => 1, "second" => 2, "third" => 3, "4th" => 4]

//Non-array values ​​can also be combined
$arrayUtils->concat(4, 5, 6);
// expected output: ["first" => 1, "second" => 2, "third" => 3, 4, 5, 6]

Syntax

$arrayUtils->concatSoft(mixed ...$values) : ArrayUtils;

Parameter

  • $values

    A new array or value to merge with the existing array. If is not array (Immutable into an array), It will be wrapped in array.

    Return value

    • A merged array. The same key values ​​are ignored.

Prefixing

$arrayUtils->concatSoftAs(mixed ...$values) : array;
ArrayUtils::concatSoftFrom(mixed ...$values) : ArrayUtils;
ArrayUtils::chunkFromAsconcatSoftFromAs(mixed ...$values) : array;

References

Previousconcat()NextcountValues()

Last updated 4 years ago

concat()