문제

$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