-1

I want to cut text after find ","

input text > 12223443,3532432

I want > 12223443

**text length is no fixed

ARR.s
  • 769
  • 4
  • 20
  • 39

1 Answers1

3

You can try with explode() function :

<?php
$parts = explode(',', "12223443,3532432");
echo $parts[0];

Or as @JustOnUnderMillions said with substr() and strpos() functions :

<?php
echo substr("12223443,3532432", 0, strpos("12223443,3532432", ','));

Or even with strstr and PHP 5.3+ (@sidyll and @JustOnUnderMillions) :

<?php
echo strstr("12223443,3532432", ',', true);
Guillaume Sainthillier
  • 1,655
  • 1
  • 9
  • 13
  • 1
    Just updated my answer to let him choose between all solutions ;-) – Guillaume Sainthillier Mar 07 '17 at 14:11
  • The *actual* reason you were downvoted originally is two-fold. First, the question is overly broad and the OP showed no effort in solving the problem. Second, there is a duplicate question which we should all search for first. – Jay Blanchard Mar 07 '17 at 17:13