Архив

Февраль 2013

Всего: 13 записей

preg_replace: заменить все input на их value

В примере у input id в формате inp1 по порядку.

if($matchcount=preg_match_all('@value="([^"]*)"@',$email_content_text,$m)){
	for($i=0;$i<=$matchcount;$i++){
		$email_content_text=preg_replace('/<input id="inp'.$i.'"[^>]*>/is',$m[1][$i],$email_content_text);
	}
}

Обновлено: чтобы не обязательно нужно было указывать id у input, но первый атрибут должен быть value, т.е <input value="1" type="text"…

if($matchcount=preg_match_all('@value="([^"]*)"@',$email_content_text,$m)){
	for($i=0;$i<=$matchcount;$i++){
		$email_content_text=preg_replace('/<input value="'.$m[1][$i].'"[^>]*>/is',$m[1][$i],$email_content_text);
	}
}

css: своя стрелка для select

html:

<div class="select_cnt">
	<select id="selectid" name="selectname">
		<option value="1">вариант 1</option>
		<option value="2">вариант 2</option>
	</select>
</div>

css:

.select_cnt {
	width:180px;
	height:20px;
	overflow:hidden;
	float:right;
	margin-right:20px;
	background:url('/img/cat_select.png') no-repeat right;
}
.select_cnt select {
	width:200px;
	height:20px;
	border:none;
	background-color:transparent;
	background-color: rgba(0,0,0,0);
}