Frage

$base64image = "data:image/png;base64,iVBOR(...)5CYII=";

I need to cut off the first part of the string and stop when the comma is cut off, so only "iVBOR(...)5CYII=" remains, since I'm using a function that doesn't support the current format using the "data:image/;base64," at the beginning, I need it to be always cut off the string.

PS: The length of the string before the commas can differ :/

How could I achieve this?

War es hilfreich?

Lösung

Try this

$result = substr(strstr($base64image, ','), 1);

Andere Tipps

A combination of strpos, and substr like so...

$comma_pos = strpos($base64image,',');
$base64image = substr($base64image,$comma_pos + 1);

Another one using explode:

echo explode(",", $base64image)[1];

outputs:

iVBOR(...)5CYII=
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top