如何在codeigniter中拆分student_no?
当我单击完成按钮时,我想增加 Student_no 。
student_no : ABS10000
所以我想拆分student_no并增加一个。如何?
我可以使用character_limiter()吗?
$string1 = "ABS100000";
$string1 = character_limiter($string1, 2);
$string2 = "ABS100000";
$string2 = character_limiter($string2, 3,8);
$string = $string + 1;
echo $string1;
echo $string2;
这是正确的...
I want increase the student_no, when i click the finish button.
student_no : ABS10000
So i want to split the student_no and increase one. How?
Can i use character_limiter()?
$string1 = "ABS100000";
$string1 = character_limiter($string1, 2);
$string2 = "ABS100000";
$string2 = character_limiter($string2, 3,8);
$string = $string + 1;
echo $string1;
echo $string2;
This is correct...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用该辅助函数的方式非常错误。另外,您的代码在某些时候没有什么意义。
character_limiter()
属于Text helper,它的目的主要是提供格式化方面的帮助;看看配套的功能,你就会看到它。另外,第三个(可选)参数应该是附加在修剪字符串末尾的文本,例如省略号。根据您的初衷,您的第二个示例“将字符串限制为 3 个字符并在末尾添加 8”,这显然是错误的。
我不知道有任何帮助器函数(这里或其他帮助器)可以做你想做的事情,但由于你在 php 中编码,我不知道为什么不能只做类似的事情(我知道可能有是更好的方法来做到这一点):
我假设“ABS”是固定的,您只想增加该字符串的数字部分。如果不是,请在您的问题中更清楚并添加相关信息。
You're using that helper function quite wrong. Also, your code makes little sense at some points.
character_limiter()
belongs to the Text helper, it's aim is to provide help in formatting, mostly; look at the companion functions and you will see it.Also, the third (optional) parameter should be a text appended at the end of the trimmed string, something such an ellipsis, for ex. Your second example, which tells to "limit the string to 3 characters and add and 8 at the end" is just plainly wrong, according to your original intentions.
I'm not aware of any helper function (here or in other helpers) that can do what you want, but since you're coding in php, I don't know why can't just do something like (I know there might be better ways to do this):
I'm assuming 'ABS' is something fixed and you just want to increment the numerical part of this string.If not, please be more clear in you question and add the relevant informations.