-2

How to get specific string from string in php? I have one string "Hello", so I want only "He". How is it possible with function or other method?

Marko Popovic
  • 3,771
  • 3
  • 19
  • 35

1 Answers1

0

You should learn about string functions.

<?php
     $startPosition = 0; // INITIALIZE FROM WHICH POINT YOU WANT TO TAKE CHARACTERS
     $characters = 2; // INITIALIZE NUMBER OF CHARACTERS YOU REQUIRED
     $string = 'Hello'; // INITALIZE YOUR STRING 
     $string1 = substr($string, $startPosition, $characters); // STRING FUNCTION
?>
Butterfly
  • 2,418
  • 5
  • 30
  • 49