How do i get email from string php


 

For get email id from string. you heve to set reguler expression.

/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i

Below is a exmaple for get email from given string in PHP

<?php

$string = "My email id is jainish.online@gmail.com and also second email id is xyz@gmail.com";

preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);

print(implode("<br>", $matches[0]));

?>

OUTPUT

jainish.online@gmail.com
xyz@gmail.com

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Typo3 database related class function : t3lib_DB Class Reference


Public Member Functions

  exec_INSERTquery ($table, $fields_values, $no_quote_fields=FALSE)
 
  exec_INSERTmultipleRows ($table, array $fields, array $rows, $no_quote_fields=FALSE)
 
  exec_UPDATEquery ($table, $where, $fields_values, $no_quote_fields=FALSE)
 
  exec_DELETEquery ($table, $where)
 
  exec_SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= ”, $orderBy= ”, $limit= ”)
 
  exec_SELECT_mm_query ($select, $local_table, $mm_table, $foreign_table, $whereClause= ”, $groupBy= ”, $orderBy= ”, $limit= ”)
 
  exec_SELECT_queryArray ($queryParts)
 
  exec_SELECTgetRows ($select_fields, $from_table, $where_clause, $groupBy= ”, $orderBy= ”, $limit= ”, $uidIndexField= ”)
 
  exec_SELECTgetSingleRow ($select_fields, $from_table, $where_clause, $groupBy= ”, $orderBy= ”, $numIndex=FALSE)
 
  exec_SELECTcountRows ($field, $table, $where= ”)
 
  exec_TRUNCATEquery ($table)
 
  INSERTquery ($table, $fields_values, $no_quote_fields=FALSE)
 
  INSERTmultipleRows ($table, array $fields, array $rows, $no_quote_fields=FALSE)
 
  UPDATEquery ($table, $where, $fields_values, $no_quote_fields=FALSE)
 
  DELETEquery ($table, $where)
 
  SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= ”, $orderBy= ”, $limit= ”)
 
  SELECTsubquery ($select_fields, $from_table, $where_clause)
 
  TRUNCATEquery ($table)
 
  listQuery ($field, $value, $table)
 
  searchQuery ($searchWords, $fields, $table)
 
  prepare_SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= ”, $orderBy= ”, $limit= ”, array $input_parameters=array())
 
  prepare_SELECTqueryArray (array $queryParts, array $input_parameters=array())
 
  exec_PREPAREDquery ($query, array $queryComponents)
 
  fullQuoteStr ($str, $table)
 
  fullQuoteArray ($arr, $table, $noQuote=FALSE)
 
  quoteStr ($str, $table)
 
  escapeStrForLike ($str, $table)
 
  cleanIntArray ($arr)
 
  cleanIntList ($list)
 
  stripOrderBy ($str)
 
  stripGroupBy ($str)
 
  splitGroupOrderLimit ($str)
 
  sql_query ($query)
 
  sql_error ()
 
  sql_errno ()
 
  sql_num_rows ($res)
 
  sql_fetch_assoc ($res)
 
  sql_fetch_row ($res)
 
  sql_free_result ($res)
 
  sql_insert_id ()
 
  sql_affected_rows ()
 
  sql_data_seek ($res, $seek)
 
  sql_field_type ($res, $pointer)
 
  sql_pconnect ($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)
 
  sql_select_db ($TYPO3_db)
 
  admin_get_dbs ()
 
  admin_get_tables ()
 
  admin_get_fields ($tableName)
 
  admin_get_keys ($tableName)
 
  admin_get_charsets ()
 
  admin_query ($query)
 
  connectDB ($host=TYPO3_db_host, $user=TYPO3_db_username, $password=TYPO3_db_password, $db=TYPO3_db)
 
  isConnected ()
 
  debug ($func, $query= ”)
 
  debug_check_recordset ($res)
 

Public Attributes

  $debugOutput = FALSE
 
  $debug_lastBuiltQuery = ”
 
  $store_lastBuiltQuery = FALSE
 
  $explainOutput = 0
 
  $link = FALSE
 
  $default_charset = ‘utf8’
 

Protected Member Functions

  setSqlMode ()
 
  explain ($query, $from_table, $row_count)
 

If you have any query then feel free to contact me at Jainish Senjaliya

Google Analytics


<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXXX-1’]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘http://www&#8217;) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

Note the UA-XXXXXXXX placeholder — replace this with your unique tracking code. Your Google Analytics code can also be pasted entirely in the “from <script> to </script>” section of the function; in most cases, only the UA- number would change.

https://www.google.com/analytics/web/provision?et=&hl=en&authuser=#provision/SignUp/

If you have any query then feel free to contact me at Jainish Senjaliya

How to Detect Default Client’s Browser Language Using PHP


The following code will be able to detect default client’s browser language. I have tested this code by using Mozilla Firefox (FF) version 3.5.2 and Internet Explorer (IE) version 8 browser. Both of those browsers worked like a charm! If you want to try using FF browser, go to the menu on that browser: Tools -> Options… -> Content -> Languages, then click on Choose… button. Add some languages as many as you need to the list afterwards. Try to change the position the language you want, by selecting the language first, and click the Move Up button to make it at the top of the list. Then run the following code, and you will see the output of the code is the language code that you have choosen before.

To make this code running, simply create a new file named detectbrowserlanguage.php. Copy-paste the following code below to that file and save the file. Put the file onto the root directory of your web server. Then run or call this file via your browser, for example: http://www.yourdoimain.com/detectbrowserlanguage.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
  $prefered_languages = array();
  if(preg_match_all("#([^;,]+)(;[^,0-9]*([0-9\.]+)[^,]*)?#i", 
	$_SERVER["HTTP_ACCEPT_LANGUAGE"], 
	$matches, 
	PREG_SET_ORDER)) {
    $priority = 1.0;
    foreach($matches as $match) {
      if(!isset($match[3])) {
        $pr = $priority;
        $priority -= 0.001;
      } else {
        $pr = floatval($match[3]);
      }
      $prefered_languages[$match[1]] = $pr;
    }
    arsort($prefered_languages, SORT_NUMERIC);
    foreach($prefered_languages as $language => $priority) {
      echo "This browser using language code: ".$language;
      exit;
    }
  }
?>

Each time after you change the language at the first position on the list, then try to run again the code above via browser. You should see the result is the same language code with the one you have just changed before. This code sometimes you need when you want to make the different handling for the certain language according to the browser’s client when they access your website.

If you have any query then feel free to contact me at Jainish Senjaliya

Create a Ajax based Form Submission with jQuery OR How To Submit a Form with jQuery and AJAX


$.ajax({type:’POST’, url: ‘jQuery-ajax-demo.php’, data:$(‘#ContactForm’).serialize(), success: function(response) {

  • $(‘#ContactForm’).find(‘.form_result’).html(response);

}})

OR

$.post(‘index.php?eID=tx_jscontactlocator’,{searchLocation:$(‘#frmContactLocator’).serialize()},function(data){

  • alert(data);

});

If you have any query then feel free to contact me at Jainish Senjaliya

tt_news: no news_id given when changing language in single view


lib.tslangmenu = COA
lib.tslangmenu {
    10 = HTML
    10.value(
        <img src=”fileadmin/templates/images/languages_en.png” width=”48″ height=”121″ alt=”Languages” />
        <div id=”LanguageContents”>
    )

    20 = HMENU
    20.special = language
    20.wrap = <div id=”AvailableLanguages”>|</div>
    20.special.value = 0,1
    20.1 = GMENU
    20.1.NO {
        XY = 24,16
        5 = IMAGE
        5.file = fileadmin/templates/images/deutsch.png || fileadmin/templates/images/englisch.png
        additionalParams.cObject = COA
        additionalParams.cObject {
            5 = TEXT
            5.wrap = &L=1

            10 = TEXT
            10.data = GPvar : tx_ttnews | backPid
            10.wrap = &tx_ttnews[backPid]=|
            10.required = 1

            20 = TEXT
            20.data = GPvar : tx_ttnews | tt_news
            20.wrap = &tx_tt_news[tt_news]=|
            20.required = 1

            30 = TEXT
            30.data = GPvar : cHash
            30.wrap = &cHash=|
            30.required = 1
        }
    }

    30 = HTML
    30.value(
        <img src=”fileadmin/templates/images/languages_en.png” width=”48″ height=”121″ alt=”Languages” />
        </div>
    )

According to the information I found I should use additionalParams and set the parameter with GPVar. But I always get the no news_id given message.

Here is my RealURL Config:

$GLOBALS[‘TYPO3_CONF_VARS’][‘EXTCONF’][‘realurl’] = array (
    ‘_DEFAULT’ => array (
        ‘init’ => array (
            ‘enableCHashCache’ => ‘1’,
            ‘appendMissingSlash’ => ‘ifNotFile’,
            ‘enableUrlDecodeCache’ => ‘1’,
            ‘enableUrlEncodeCache’ => ‘1’,
        ),
    ‘redirects’ => array (
        ),
        ‘preVars’ => array (
            ‘0’ => array (
                ‘GETvar’ => ‘no_cache’,
                ‘valueMap’ => array (
                    ‘nc’ => ‘1’,
                ),
                ‘noMatch’ => ‘bypass’
            ),
            ‘1’ => array (
                ‘GETvar’ => ‘L’,
                ‘valueMap’ => array (
                    ‘de’ => ‘0’,
                    ‘en’ => ‘1’,
                ),
                ‘valueDefault’ => ‘de’,
                ‘noMatch’ => ‘bypass’,
            ),
            ‘2’ => array (
                ‘GETvar’ => ‘lang’,
                ‘valueMap’ => array (
                    ‘de’ => ‘de’,
                    ‘en’ => ‘en’,
                ),
            ‘noMatch’ => ‘bypass’,
            ),
        ),

        ‘pagePath’ => array (
            ‘type’ => ‘user’,
            ‘userFunc’ => ‘EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main’,
            ‘spaceCharacter’ => ‘-‘,
            ‘languageGetVar’ => ‘L’,
            ‘expireDays’ => ‘7’,
            ‘rootpage_id’ => ‘1’,
        ),
        ‘fixedPostVars’ => array (
        ),
        ‘postVarSets’ => array (
            ‘_DEFAULT’ => array (
                ‘archive’ => array (
                    ‘0’ => array (
                        ‘GETvar’ => ‘tx_ttnews[year]’,
                        ),
                    ‘1’ => array (
                        ‘GETvar’ => ‘tx_ttnews[month]’,
                        ‘valueMap’ => array (
                        ‘january’ => ’01’,
                        ‘february’ => ’02’,
                        ‘march’ => ’03’,
                        ‘april’ => ’04’,
                        ‘may’ => ’05’,
                        ‘june’ => ’06’,
                        ‘july’ => ’07’,
                        ‘august’ => ’08’,
                        ‘september’ => ’09’,
                        ‘october’ => ’10’,
                        ‘november’ => ’11’,
                        ‘december’ => ’12’,
                    ),
                ),
            ),
            ‘browse’ => array (
                ‘0’ => array (
                    ‘GETvar’ => ‘tx_ttnews[pointer]’,
                ),
            ),
            ‘select_category’ => array (
                ‘0’ => array (
                    ‘GETvar’ => ‘tx_ttnews[cat]’,
                ),
            ),
            ‘article’ => array(
                array(
                    ‘GETvar’ => ‘tx_ttnews[pointer]’,
                    ‘valueMap’ => array(),
                    ‘noMatch’ => ‘bypass’,
                ),
                array(
                    ‘GETvar’ => ‘tx_ttnews[tt_news]’,
                    ‘lookUpTable’ => array(
                    ‘table’ => ‘tt_news’,
                    ‘id_field’ => ‘uid’,
                    ‘alias_field’ => ‘title’,
                    ‘addWhereClause’ => ‘ AND NOT deleted’,
                    ‘useUniqueCache’ => 1,
                    ‘useUniqueCache_conf’ => array(
                        ‘strtolower’ => 1,
                        ‘spaceCharacter’ => ‘-‘,
                    ),
                    ‘languageGetVar’ => ‘L’,
                    ‘languageExceptionUids’ => ”,
                    ‘languageField’ => ‘sys_language_uid’,
                    ‘transOrigPointerField’ => ‘l18n_parent’,
                    ‘autoUpdate’ => 1,
                    ‘expireDays’ => 180,
                ),
            ),
            array (
                ‘GETvar’ => ‘tx_ttnews[swords]’,
            ),
        ),
    ),
),

SCRIPT438: Object doesn’t support property or method


It was recently brought to my attention that one of my websites was not functioning correctly in Internet Explorer 9. Parts of the page and javascript would load, however the AJAX portions of the site failed to load.

Using the F12 Developer tools package with IE9 I was able to find the error:

1
2
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.js, line 16 character 59007
1
2
SCRIPT438: Object doesn't support property or method'getElementsByClassName'
jquery.js, line 3  character 22085

The solution is simple, update your jQuery to the latest version (at the time of this writing, 1.6.2). The version I had installed on the website (1.5) is not compatible with IE9.