-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,999
  • 3
  • 22
  • 37

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
?>
Anto S
  • 2,448
  • 6
  • 32
  • 50