Skip to content

Instantly share code, notes, and snippets.

@bertani
Created March 20, 2017 10:02
Show Gist options
  • Save bertani/0bdb1dac1e2bfdc29ba16011c5839f17 to your computer and use it in GitHub Desktop.
Save bertani/0bdb1dac1e2bfdc29ba16011c5839f17 to your computer and use it in GitHub Desktop.
function strConcat(string _a, string _b, string _c, string _d, string _e, string _f, string _g) internal returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
bytes memory _bc = bytes(_c);
bytes memory _bd = bytes(_d);
bytes memory _be = bytes(_e);
bytes memory _bf = bytes(_f);
bytes memory _bg = bytes(_g);
string memory abcdefg = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length + _bf.length + _bg.length);
bytes memory babcdefg = bytes(abcdefg);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) babcdefg[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) babcdefg[k++] = _bb[i];
for (i = 0; i < _bc.length; i++) babcdefg[k++] = _bc[i];
for (i = 0; i < _bd.length; i++) babcdefg[k++] = _bd[i];
for (i = 0; i < _be.length; i++) babcdefg[k++] = _be[i];
for (i = 0; i < _bf.length; i++) babcdefg[k++] = _bf[i];
for (i = 0; i < _bg.length; i++) babcdefg[k++] = _bg[i];
return string(babcdefg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment