there is an array, there is text in it that contains links, and there is just text.

foreach ($arrayData['messages'] as $item) { if (preg_match('#^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$#i', $item['content'])) { $values[] = [date('Ymd H:i:s', $item['timestamp_ms'] / 1000), $item['sender_name'], $item['content'], isset($item['share']) ? $item['share']['link'] : null]; } } 

I want to pull the values ​​of $ item ['content'] in which there is both a link and text.

    1 answer 1

    decided

     $reg = '/(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[az\d\x{00a1}-\x{ffff}]+-?)*[az\d\x{00a1}-\x{ffff}]+)(?:\.(?:[az\d\x{00a1}-\x{ffff}]+-?)*[az\d\x{00a1}-\x{ffff}]+)*(?:\.[az\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?/uim'; foreach ($arrayData['messages'] as $item) { if (preg_match_all($reg, $item['content'])) { $values[] = [date('Ymd H:i:s', $item['timestamp_ms'] / 1000), $item['sender_name'], $item['content'], isset($item['share']) ? $item['share']['link'] : null]; } }