标签:
<?php
$str = ‘hello php java C# C++‘;
echo $str.‘<br>‘;
echo strpos($str,‘o‘).‘<br>‘; //‘o‘ ‘ph‘
$str1 = substr($str,2,3); //($str,2)
echo $str1.‘<br>‘;
$result1 = str_split($str,2);// ($str)=($str,1)
print_r($result1); //print array
echo ‘<br>‘;
$result2 = explode(‘ ‘,$str);
print_r($result2);
echo ‘<br>‘;
$num = 100;
$str2 = $str.‘<br>Objective-C ‘.$num; //OR: "$str<br>Objective-C $num";
echo $str2;
结果:
hello php java C# C++
4
llo
Array ( [0] => he [1] => ll [2] => o [3] => ph [4] => p [5] => ja [6] => va [7] => C [8] => # [9] => C+ [10] => + )
Array ( [0] => hello [1] => php [2] => java [3] => C# [4] => C++ )
hello php java C# C++
Objective-C 100
标签:
原文地址:http://www.cnblogs.com/htmlphp/p/4842125.html