<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>piouPiouM&#039;s dev&#187; Archives pour le tag gist – piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/tag/gist/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Thu, 05 Aug 2010 13:48:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</title>
		<link>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html</link>
		<comments>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html#comments</comments>
		<pubDate>Sun, 28 Feb 2010 18:17:12 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=336</guid>
		<description><![CDATA[Une fonction PHP utilitaire pour convertir une chaîne en notation CamelCase en mots réunis par un séparateur (par défaut, le caractère underscore _).

La fonction uncamel() supporte indifféremment, en entrée, les notations lowerCamelCase et UpperCamelCase.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
&#60;?php
/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une fonction <strong><a href="http://fr.wikipedia.org/wiki/PHP" title="PHP: Hypertext Preprocessor - Wikipédia">PHP</a></strong> utilitaire pour convertir une chaîne en notation <strong><a href="http://fr.wikipedia.org/wiki/CamelCase" title="CamelCase - Wikipédia">CamelCase</a></strong> en mots réunis par un séparateur (par défaut, le caractère <em>underscore</em> <code>_</code>).</p>

<p>La fonction <strong><code>uncamel()</code></strong> supporte indifféremment, en entrée, les notations <strong>lowerCamelCase</strong> et <strong>UpperCamelCase</strong>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     uncamel('UpperCamelCase') === 'upper_camel_case'
 *     uncamel('ThisIsAString') === 'this_is_a_string'
 *     uncamel('notcamelcase') === 'notcamelcase'
 *     uncamel('lowerCamelCase', ' | ') === 'lower | camel | case'
 *
 * @author    Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright 2010 Mehdi Kabab
 * @license   http://www.opensource.org/licenses/mit-license.html MIT License
 * @link      http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html
 *
 * @param  string $content The CamelCase string.
 * @param  string $separator The glue for the compound words. Defaults to '_'.
 * @return string
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> uncamel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#(?&lt;=[a-zA-Z])([A-Z])(?=[a-zA-Z])#e'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;'<span style="color: #006699; font-weight: bold;">$separator</span>' . strtolower('<span style="color: #006699; font-weight: bold;">$1</span>')&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Le <a href="http://gist.github.com/317702" title="gist: 317702 -  GitHub">forker (gist)</a>.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html' title='Bundle License Helper pour TextMate'>Bundle License Helper pour TextMate</a></li><li><a href='http://pioupioum.fr/developpement/javascript-array-intersection.html' title='JavaScript : optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles'>JavaScript&#160;: optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
