$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?

有帮助吗?

解决方案

Try this

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

其他提示

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=
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top