首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP安装/语法/函数 » [求助]偶的小段代码之二  


  作者:小丸子
  注册时间:2005-03-04
  主题/回复:6/10
  积分:440
  等级:★★☆(五级)
  称号:略有小成

  wh2063781@sina.c..
  未提供
  www.

 

 发表:2005-03-17 01:48:40 阅读 2287 次 回复 6 次 得分1  |   字号 字色
[求助]偶的小段代码之二
<?
$str="hello,word,how,are,you";
$str1=strtok($str,",");
//echo $str1;
$s_count=0;
while($str1){
$s_count++;
echo "第".$s_count."个单词为".$str1;
echo"<BR>";
$str1=strtok("");
}
?>
显示结果为
µÚ1¸öµ¥´ÊΪhello
µÚ2¸öµ¥´ÊΪword,how,are,you
哪里出错了?

<?
$str1="Developed by a dermatologist,this in-depth consultation guides you through an expert evaluation of your skin and its needs. After you’ve completed the consultation, you’ll receive a customized product recommendation designed to help you get healthy-looking skin. The 11 questions will take approximately two minutes to answer.
"
    $str2=chunk_split($str1,76,\r\n) ;
echo str2;
?>
显示不出正确结果哈,:/
 
 1#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 1#楼 发表于2005-03-17 16:26:13  评分:1 

先说你第一个问题
你大概还没有搞清楚strtok的用法吧
这样写:
$str="hello,word,how,are,you";
$str1=strtok($str,",");
$s_count=0;
while($str1){
$s_count++;
echo "第".$s_count."个单词为".$str1;
echo"<BR>";
$str1=strtok(",");
}
这样就可以了,至于你的中文显示乱码,这和PHP没关系了。检查一下apache配置把

第二个问题,$str2=chunk_split($str1) ;就好了不必加参数。
 

 2#楼  
 
  回复人:小丸子
  注册时间:2005-03-04
  主题/回复:6/10
  积分:440
  等级:★★☆(五级)
  称号:略有小成

   
 2#楼 发表于2005-03-17 18:00:09  评分:× 

谢谢高手,我小粗心,第一个问题解决了.但是$str2=chunk_split($str1) ;
还是没有解决问题啊,还是不能正常显示结果
 3#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 3#楼 发表于2005-03-17 23:14:06  评分: 

。。。
输出了什么东西?你认为因该输出什么呢?

还有,echo str2;也不对阿,应该是 echo $str2;
 4#楼  
 
  回复人:小丸子
  注册时间:2005-03-04
  主题/回复:6/10
  积分:440
  等级:★★☆(五级)
  称号:略有小成

   
 4#楼 发表于2005-03-18 00:48:46  评分:× 

Parse error: parse error in D:\web\Untitled-8.php on line 12(输出结果)
我理解这个函数的功能是把我提供的字符串按每76个字符进行分割
请高手再次指教
 5#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 5#楼 发表于2005-03-18 01:01:37  评分: 

...
郁闷,看看你的代码
----------------------
<?
$str1="Developed by a dermatologist,this in-depth consultation guides you through an expert evaluation of your skin and its needs. After you’ve completed the consultation, you’ll receive a customized product recommendation designed to help you get healthy-looking skin. The 11 questions will take approximately two minutes to answer.
"
    $str2=chunk_split($str1,76,\r\n) ;
echo str2;
?>
----------------------------------
少了什么呢?说出来都能吓人一跳,少了“;”,分号!
$str1="Developed by..................."  //这里少了分号吧~
$str2=......
 6#楼  
 
  回复人:小丸子
  注册时间:2005-03-04
  主题/回复:6/10
  积分:440
  等级:★★☆(五级)
  称号:略有小成

   
 6#楼 发表于2005-03-21 17:46:09  评分:× 

哦,没脸见人啦.555555555555555555555555555555555
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.006sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版