Here’s one way:
$print = preg_replace('/^([^,]*).*$/', '$1', $print);
Another:
list($print) = explode(',', $print);
Or:
$print = explode(',', $print)[0];
More Related Contents:
- PHP – Replace part of a string [closed]
- How do I check if a string contains a specific word?
- How to get a substring between two strings in PHP?
- PHP string replace match whole word
- What is so wrong with extract()?
- How to remove line breaks (no characters!) from the string?
- Making sure PHP substr finishes on a word not a character
- How to replace different newline styles in PHP the smartest way?
- how to replace special characters with the ones they’re based on in PHP?
- Replace last occurrence of a string in a string
- How to get first 5 characters from string [duplicate]
- Replace a whole line where a particular word is found in a text file
- Get min and max value in PHP Array
- PHP substring extraction. Get the string before the first ‘/’ or the whole string
- Convert all types of smart quotes with PHP
- PHP String Manipulation: Extract hrefs
- How to retrieve comments from within an XML Document in PHP
- Replace string in an array with PHP [closed]
- How to get the first word of a sentence in PHP?
- PHP – Replace colour within image
- PHP remove commas from numeric strings
- PHP function to replace a (i)th-position character
- Find and replace in a file
- Check if variable starts with ‘http’
- PHP extract link from tag [duplicate]
- Remove or match a Unicode Zero Width Space PHP
- What is the fastest way to find the occurrence of a string in another string? [duplicate]
- find and replace keywords by hyperlinks in an html fragment, via php dom
- Search and replace multiple values with multiple/different values in PHP?
- Simple: How to replace “all between” with php? [duplicate]