var_export to string

Cacao Meravigliao picture Cacao Meravigliao · Nov 28, 2012 · Viewed 10.3k times · Source

I have an HTML code in the $output string, this code is delimited by two terms: -startMiniPreview- and -endMiniPreview-. I need to take the part wrapped between those two terms and save it in another string variable. This is what I thought was the right way to do so, but it's not working at all. The HTMLCODE part is getting exported succesfully but not as a string

    $output="-startMiniPreview-HTMLCODE-endMiniPreview-EXTRA";
    preg_match( '/\-startMiniPreview-(.*?)\-endMiniPreview/', $output,$vt);
    $cutOut=strval(var_export($vt[1]));

Answer

Niet the Dark Absol picture Niet the Dark Absol · Nov 28, 2012

The documentation clearly gives the answer:

$cutOut = var_export($vt[1],true);

EDIT: That said, why are you doing this? Just $cutOut = $vt[1]; is all you need.