hi there
I am having a small query regarding php programming language. My question is What is the php regular expression to get everything before a certain character?
Please help me regarding this problem
Your views will be appreciated
hi there
I am having a small query regarding php programming language. My question is What is the php regular expression to get everything before a certain character?
Please help me regarding this problem
Your views will be appreciated
Whatever you place in your regular expression you want to encase in in parenthesis and those items will be returned in their own array...
I can never get it first time around but I imagine it would be something like this.
Code:
preg_match('@table(.*?)[:]{1}(.*?)@si',$string,$matches);
print('<pre>');
print_r($matches);
print('</pre>');
function LimitText($Text,$Min,$Max,$MinAddChar) {
if (strlen($Text) < $Min) {
$Limit = $Min-strlen($Text);
$Text .= $MinAddChar;
}
elseif (strlen($Text) >= $Max) {
$words = explode(" ", $Text);
$check=1;
while (strlen($Text) >= $Max) {
$c=count($words)-$check;
$Text=substr($Text,0,(strlen($words[$c])+1)*(-1));
$check++;
}
}
return $Text;
}
function explode_escaped($delimiter, $string){
$exploded = explode($delimiter, $string);
$fixed = array();
for($k = 0, $l = count($exploded); $k < $l; ++$k){
if($exploded[$k][strlen($exploded[$k]) - 1] == '\\') {
if($k + 1 >= $l) {
$fixed[] = trim($exploded[$k]);
break;
}
$exploded[$k][strlen($exploded[$k]) - 1] = $delimiter;
$exploded[$k] .= $exploded[$k + 1];
array_splice($exploded, $k + 1, 1);
--$l;
--$k;
} else $fixed[] = trim($exploded[$k]);
}
return $fixed;
}
Bookmarks