<?php

$text = "Today is | nice day | go to | school now | and enjoy | your life |.";
echo $text; echo "\r\n\r\n";

$text = preg_replace("~\| (.*?) \|~", '"$1"', $text);
echo $text; echo "\r\n\r\n";