Jump to content

hackerspk

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hackerspk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. need to track where you are currently with regards to the heading number you're at, and track levels. The basic theory is this. When you hit your first [H1], you increment the counter to 1. When you hit the h2, your second level counter is incremented to 1. When you hit the h3, your third level counter is incremented to 1. This will obviously output 1.1.1. Now when you hit the next h1, they sub levels (ie not the main level) are reset to 0, and then the first level is incremented to 2. You hit the h2, and it goes to 1 again... Then you have first level 2, sub 1, sub 1 = 2.1.1. i have this idea but i dont know how to implement it any one please ?
  2. Ok yesterday i asked for help in my FAQ script and some one help me very well and iam successfully make the script but now i want to make List of contents just like in wikipedia My code is <?php $str = "[H1]Top Heading[/H1] My test string [H2]My sub Heading[/H2] My second [H3]My deep Heading[/H3] string now again [H1]Top Heading[/H1] My test string [H2]My sub Heading[/H2] My second [H3]My deep Heading[/H3]"; /** * Helper class */ class FaqHelper { static $count = 1; static $listItems = array(); static $prefix = 'faq-'; static function GetList() { $items = ''; foreach (self::$listItems as $id => $label) { $items .= '<li><a href="#' . self::$prefix . $id .'">' . $label . '</a></li>'; } return '<ul>'. $items .'</ul>'; } static function ReplaceCallback($matches) { $id = self::$count; $label = $matches[1]; self::$listItems[$id] = $label; $res = '<font size=\"7"><span id=\"'. self::$prefix . $id .'">' . $label . '</span></font><hr />'; self::$count++; return $res; } } $text = preg_replace_callback( "#\[HD1\]([^\[]+)\[/HD1\]#", array('FaqHelper', "ReplaceCallback"), $str ); $list = FaqHelper::GetList(); echo $list; echo '<br /><br />'; echo $text; ?> and this gives 1. Top Heading 2. Top Heading Top Heading My test string [H2]My sub Heading[/H2] My second [H3]My deep Heading[/H3] string now again Top Heading My test string [H2]My sub Heading[/H2] My second [H3]My deep Heading[/H3] but i want this results 1. Top Heading 1.1 My sub Heading 1.1.1 My deep Heading 2. Top Heading 2.1 My sub Heading 2.1.1 My deep Heading Top Heading My test string My sub Heading My second My deep Heading string now again Top Heading My test string My sub Heading My second My deep Heading string now again So on ...
  3. ok i got the soloution <?php $str = "[H]Test[/H] My test string [H]Test2[/H] My second Test string"; /** * Helper class */ class FaqHelper { static $count = 1; static $listItems = array(); static $prefix = 'faq-'; static function GetList() { $items = ''; foreach (self::$listItems as $id => $label) { $items .= '<li><a href="#' . self::$prefix . $id .'">' . $label . '</a></li>'; } return '<ul>'. $items .'</ul>'; } } // the callback function function make_faq($matches) { $id = FaqHelper::$count; $label = $matches[1]; FaqHelper::$listItems[$id] = $label; $res = '<span id="'. FaqHelper::$prefix . $id .'">' . $label . '</span>'; FaqHelper::$count++; return $res; } $text = preg_replace_callback( "#\[H\]([^\[]+)\[/H\]#", "make_faq", $str ); $list = FaqHelper::GetList(); echo $list; echo '<br /><br />'; echo $text; ?>
  4. iam unable to list all the words or sentenses inside th [H] [/H] tags and then adding numbring to the links like <a name="faq-1"></a>Test = how to add 1 <a name="faq-2"></a>Test2 = how to add 2 my code is $str = "this is [H]test[/H] this is 2nd [H]test[/H]"; $str = preg_replace("/\[H](.*?)\[/H]/is","<a name=\"faq-$i++\"></a>$1",$str); echo $str;
  5. i have a string for example $str = "[H]Test[/H] My test string [H]Test2[/H] My second Test string"; and i want to make a list inside "[H]" and make them click able like <a href="#faq-1">Test</a> <a href="#faq-2">Test2</a> and and also want to include this <a name="faq-1"></a>Test <a name="faq-2"></a>Test2 in $str any help please
  6. i have a long string like $str = "this is [my] test [string] and [string] is very long [with] so many pwords]" i know str_replace fuction but when i replace i got this result $str = str_replace( "[", "<a href=\"http://localhost/salar/story.php?urdu=,$str; $str = str_replace( ]", "\"></a>",$str; <a href="/index.php?word=test"></a> but i want this result for each word in [] <a href="/index.php?word=test">test</a>
  7. i have a string e.g $str = "This is my [Test] string"; i want to make it like this <a href="/index.php?word=Test">Test</a> means every word inside [] convert to click able link Thanks
  8. if there is no solution for it ?
  9. yes you are true in starting i want to make a link on it but now i think to translate whole paragraph using this code $user_name = "root"; $password = ""; $database = "salar"; $server = "127.0.0.1"; $mydata = "text to translate"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SET NAMES 'utf8'"; $SQL = "SELECT * FROM dle_roman ORDER BY LENGTH( roman ) DESC"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { $mydata = str_replace ($db_field['urdu'],$db_field['roman'],$mydata); } echo $mydata; mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); }
  10. i just want to make a translator which tranlate from Urdu to Roman language for my site i have complete dictionary for this puorpose i just need a page who translate . thanks for your reply
  11. oh ! please tell me how will it work good and fast ? thanks
  12. hi listen this is a translator of a language Urdu to roman it translate on base of words for example player = blayer wild = vild so on and it work very good with 50000 words but when i increase the dictionary it is not working and also $mydata just display translated list of words if thery are in first row or in last. these are the results but i dont know if this code is good or bad help me please
  13. iam not displaying 83000 pieces on one page it just replace a list of words with a hyperlink on them. but i think it will search for each word 83000 times. if iam true ?
  14. i got this error  Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\salar\engine\modules\show.full.php on line 623 and i also use mysql_query($SQL,$db_handle); but i got same result  Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\salar\engine\modules\show.full.php on line 623 and i also creat a new user for it but it not works
  15. i am a newbie i make this script to add automatic link (href) in my site its working but i have 83000 titles in mysql dabase so this script is not executing now if there is any way to make this one better or there is an other way to do this work thanks $user_name = "root"; $password = ""; $database = "salar"; $server = "127.0.0.1"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SET NAMES 'utf8'"; mysql_query($SQL); $SQL = "SELECT * FROM dle_mylinks ORDER BY LENGTH( title ) DESC"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { $row['full_story'] = str_replace ($db_field['title'],"<a href=\"?newsid=" . $db_field['id'] . "\">" . $db_field['title'] . "</a>" ,$row['full_story']); $row['short_story'] = str_replace ($db_field['title'],"<a href=\"?newsid=" . $db_field['id'] . "\">" . $db_field['title'] . "</a>" ,$row['short_story']); } $mydata =$row['short_story'] . $row['full_story']; mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.