PHP 8.5.0 Alpha 1 available for testing

Voting

: max(three, one)?
(Example: nine)

The Note You're Voting On

mark at manngo dot net
2 years ago
On thing you might want to do is replace an old string with a shorter one, or to clear out the string altogether.

To replace the string, you can zero-byte pad the string you are writing:

<?php
// $shmid is from shmop_open()
$size = 128;
$string = 'something';

// write
$string = str_pad(string, $size, "\0");
shmop_write($shmid, $string, 0);

// read
print rtrim(shmop($shmid,0,0),,"\0");

// clear
$string = str_repeat("\0",$size);
shmop_write($shmid, $string, 0);
?>

<< Back to user notes page

To Top