Hi guys, how can i get some part of string (in symbols). For example:
$string = 'one two three';
$numSymbols = 7;
%what should I do%
$res_string = 'one two';
Help, please.
Hi guys, how can i get some part of string (in symbols). For example:
$string = 'one two three';
$numSymbols = 7;
%what should I do%
$res_string = 'one two';
Help, please.
You are looking for the substr function, I'd say.
In your case, here is an example :
$string = 'one two three';
$numSymbols = 7;
$res_string = substr($string, 0, $numSymbols);
var_dump($res_string);
And you'll get :
string 'one two' (length=7)
Parameters :
You should be using substr()
Example:
$string = 'one two three';
$res_string = substr($string, 0, 7);// $res_string == 'one two'