Forum Moderators: coopster
function edit_firmness($itemid,$firmness)
{ //changes an items firmness rating
$itemidlength = strlen($itemid);
$curfirmlength = strlen($itemfirmness[$itemid]);
$finstringlength = $itemidlength - $curfirmlength -1;
$newitemid =substr($itemid, 0, $finstringlength);
$this->itemid = $newitemid;
}
To do that I recommend using to full extent function substr:
function edit_firmness($itemid,$firmness)
{ //changes an items firmness rating
$cut = strlen($itemfirmness[$itemid]) * (-1);
$newitemid =substr($itemid, 0, $cut);
$this->itemid = $newitemid;
}
It's not very correct, but a bit shorter.
I still have no idea what your function does
Michal Cibor
function change_word($str, $to, $which) {
$array = explode(" ", $str);
$array[$which] = $to;
return implode(" ", $array);
}
To change fourth word:
$str = "Standard King Size 1 £459.00";
$str3 = change_word($str, "3", 3);
//$str3 = "Standard King Size 3 £459.00";
Best regards
Michal Cibor