-3

I need to trim the title after the first comma. Remove all the words after the first comma. How can I title any code snippet?

Screenshots: https://prntscr.com/tt5x6i Code shorts: https://prntscr.com/tt5xa7

<td class="aawp-table__td-title" data-label="<?php _e('Product', 'aawp'); ?>">
    <?php echo $this->truncate( $this->get_product_title(), 100 ); ?>
</td>

Someone solved this:

<?php echo stristr($this->truncate($this->get_product_title(), 100), ',', true); ?>

But its not working somewhere, Error screenshot: https://prntscr.com/tt6fdj

Anyone here to help me, please?

Jay Blanchard
  • 33,530
  • 16
  • 73
  • 113

1 Answers1

1

You can use something like that:

$string = substr($string, 0, strpos($string, ",")); 

Tommaso
  • 109
  • 1
  • 9