首页 > 解决方案 > 在变量中获取值之后的所有内容

问题描述

$contents,我想在管道之后抓住所有东西,例如boss

$search_for = "micky.mcgurk";
$contents = "micky.mcgurk@somewebsite.com|boss";
$pattern = sprintf('/\b%s@([^|\s]+)\|/m', preg_quote($search_for));

if (preg_match_all($pattern, $contents, $matches)) {
    $submitted_by = implode("\n", $matches[1]);
} else {
   echo "No user found";
}

标签: php

解决方案


$resultat = substr(strrchr($content, '|'), 1);

推荐阅读