- substr: documentation ( source)
- strpos: documentation ( source)
<?php
$purchaseCreateAt = '20170421';
$inflowDate = '-00011130';
echo strpos($inflowDate, '-') === 0 ? $purchaseCreateAt : $inflowDate;
echo substr($inflowDate,0,1) === '-' ? $purchaseCreateAt : $inflowDate;