Skip to content

Instantly share code, notes, and snippets.

View NicTorgersen's full-sized avatar
💩
Never satisfied

Nic NicTorgersen

💩
Never satisfied
View GitHub Profile
@NicTorgersen
NicTorgersen / string-segment-test.php
Last active May 12, 2022 20:19
Split a string in PHP into segments as array
<?php
$output = [];
$lengthPerSegment = 40;
$string = "Hello, this is a string.";
foreach (str_split($string) as $index => $character) {
if ($index % $lengthPerSegment === 0) {
$output[] = substr($string, $index, $lengthPerSegment);
}

Keybase proof

I hereby claim:

  • I am nictorgersen on github.
  • I am nictorgersen (https://keybase.io/nictorgersen) on keybase.
  • I have a public key ASDQPOMRMkv7UqqefPPpvIYnJaPWlBJvR0nHRS85zmQ1Cwo

To claim this, I am signing this object: