Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
Почти всеки път текста след # ще е различен и това не ми върши работа в този случай..xmmm каза:PHP:<?php $a = '#text'; $b = explode('#', $a); if($b[1]!=NULL) { echo 'tuk e ocveten'; } ?>
Така се оцветява целия текст да края.. Пак не ставаtedo96 каза:$text = $row['text'];
if(strstr('#',$text)) {
echo 'tuk e ocveten';
}
t0shk0 каза:Почти всеки път текста след # ще е различен и това не ми върши работа в този случай..xmmm каза:PHP:<?php $a = '#text'; $b = explode('#', $a); if($b[1]!=NULL) { echo 'tuk e ocveten'; } ?>
xmmm каза:t0shk0 каза:Почти всеки път текста след # ще е различен и това не ми върши работа в този случай..xmmm каза:PHP:<?php $a = '#text'; $b = explode('#', $a); if($b[1]!=NULL) { echo 'tuk e ocveten'; } ?>
Не те разбрах, какво като е различен ? Дай пример на текст, на които няма да работи ?
t0shk0 каза:xmmm каза:t0shk0 каза:Почти всеки път текста след # ще е различен и това не ми върши работа в този случай..
Не те разбрах, какво като е различен ? Дай пример на текст, на които няма да работи ?
Така както ти си го направил ще взима само първата дума след #. Аз не знам колко думи ще има след #. Дали ще е една, десет или повече .. Може да стане само ако направя още 10-сетина проверки. Сега мисля дали може да се получи с preg_match ама се пак мерси. Ако не измисля друго ще ползвам това ..
<?php
$a = '#text';
$text = str_replace('#', ' ', $a);
$b = explode('#', $a);
if($b[1]!=NULL)
{
echo $text;
}
?>
<?php
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$fullstring = "#this is a string
another line of this string
one more";
$parsed = get_string_between($fullstring, "#", "\n");
echo $parsed;
?>
<?php
$texta = "
Lorem Ipsum is simply dummy text of
#the printing and typesetting industry.
Lorem Ipsum has been the industry's standard
#dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only
"; //text
$text2=explode("
", $texta);
$count=count($text2);
for ($i=1; $i<=$count; $i++) {
if (substr($text2[$i], 0, 2) == " #") {
$text2[$i] = "<b>".$text2[$i]."</b>";
} else {
$text2[$i] = $text2[$i];
}
echo $text2[$i]."<br />";
}
?>
Karcho каза:PHP:$text = "text from DB, may be #comment"; echo preg_replace("/\#+(.+)(\n|\r\n)?/", "<span style='color: green;'>#$1</span>$2", $text);
Note: Прави това преди да използваш функцията nl2br.
<?php
mysql_query("SET NAMES utf8");
$pon = $_GET['network'];
$result = mysql_query("SELECT * FROM clients ")
or die(mysql_error());
echo "<div id='content'><table align='center' cellspacing='0' cellpadding='0' class='sortable'>";
echo "<tr> <th width='2%'>ID</th> <th>Адрес</th> <th>Име</th> <th width='6%'>Телефон</th> <th width='6%'>Договор</th> <th width='5%'>Дата</th> <th width='5%'>Час</th> <th width='6%'>ПОН</th> <th width='9%'>МАК 1</th> <th width='9%'>МАК 2</th> <th>Забележка</th> <th width='5%'>Мрежа</th> <th width='4%'>Активен</th> <th width='3%'></th></tr>";
include('search.php');
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<td>' . $row['id'] . '</td>';
echo '<td>кв.' . $row['kvartal'] . ' бл.' . $row['blok'] . ' вх.' . $row['vhod'] . ' ет.' . $row['etaj'] . ' ап.' . $row['apartament'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['telephone'] . '</td>';
echo '<td>' . $row['contract'] . '</td>';
echo '<td>' . $row['data'] . ' ' . $row['mesec'] . '</td>';
echo '<td>' . $row['hour'] . '</td>';
echo '<td>' . $row['pon'] . '</td>';
echo '<td>' . $row['mac1'] . '</td>';
echo '<td>' . $row['mac2'] . '</td>';
echo '<td>' . $row['note'] . '</td>';
echo '<td>' . $row['network'] . '</td>';
echo '<td>' . $row['active'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '" class="button2">Промени</a></td>';
echo "</tr>";
}
echo "</table></div>";
?>
Skorostrelko каза:Интересува ме как може спрямо това дали $row['active'] е 1 или 0 да се оцветява целия ред в определен цвят? Благодаря предварително!
//...
while($row = mysql_fetch_array( $result )) {
echo $row['active']==1 ? '<tr style="color:blue">' : '<tr style="color:red;">';
echo '<td>' . $row['id'] . '</td>';
//..