there is a php variable like this $variable='a b c d
e f g h
i j k l'
is it possible to get the central line e f g h in the variable and remove the rest. provided that values of all three lines are unknown.
1 Answer
You can simply split the string, using the new line '\n' character
$mline = 'a b c d
e f g h
i j k l';
$your_array = explode("\n", $mline);
echo $your_array[1]; //Specific solution
echo $your_array[ceil(count($your_array)/2)]; //General solution
1 Comment
Abdur Rehman
thank u problem is solved. your answer was really helpful