0

I am new to php. I am trying extract a particular value from a joke file using file_get_content( text.txt, NULL,NULL, 200, 4) but it returns the values after the 200th character. please is there a better way to do this. like instead of specifying the position which may vary i specify a word rather

Abhishek kumar
  • 4,347
  • 8
  • 29
  • 44
Jillnkir
  • 15
  • 5

1 Answers1

0

Perhaps this solution might be what you are looking for?

<?php
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

if ($pos === false) {
    echo "Not found";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}
?>
kuylis
  • 11
  • 3
  • this gives the position which is not what i want. i want the value after the position – Jillnkir Aug 28 '17 at 11:29
  • Using substr('abcde', 0, 1); would get you the value at the given position. In this example it searches the string 'abcde' , starts at the first character and returns only 1 character. Is this perhaps what you're looking for? – kuylis Aug 28 '17 at 11:40