我希望从数据库中获取部分价值 我知道我必须使用拆分代码,但它将从php中删除 所以我必须使用现在的东西 例如,我有
<html>
<header>
<body>
<?php
$value = "10-20-30-40-50-87";
//i want to get 30 for example
?>
我知道我可以使用
$aryStr = split("#", $string);
print "$aryStr[0]<br>";
print "$aryStr[1]";
但它在php5.3中给我一个错误 所以我现在必须使用从价值中获得40
答案 0 :(得分:1)
使用PHP explode函数将$值拆分为字符串数组。
$value = "10-20-30-40-50-87";
$pieces = explode("-", $value);
echo $pieces[0]; // 10
echo $pieces[1]; // 20