create account

PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin ) by alexendre-maxim

View this thread on: hive.blogpeakd.comecency.com
· @alexendre-maxim ·
$18.16
PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )
<html>
<p><img src="https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg" width="2122" height="1415"/></p>
<p><a href="https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg">Image Source</a></p>
<h2>Repository</h2>
<p><a href="https://github.com/php/php-src">https://github.com/php/php-src</a> &nbsp;</p>
<h2>What Will I Learn?</h2>
<p>I will learn the string methods the second part we will take the " Bin2Hex, Count_Chars, Explode and Hex2Bin " methods</p>
<ul>
  <li>How to convert from Binary to Hexadecimal using the Bin2Hex method.</li>
  <li>What's the Count_Chars method and how to use it .</li>
  <li>How to divide the string using the Explode method.</li>
  <li>How to convert from Hexadecimal to Binary using the Hex2Bin method.</li>
</ul>
<h2>Requirements</h2>
<ul>
  <li>Server support PHP , Xampp or Wamp for example</li>
  <li>An IDE like Sublime text.</li>
  <li>Browser (Chrome for example)&nbsp;</li>
</ul>
<h2>Difficulty</h2>
<ul>
  <li>Basic</li>
</ul>
<h2>Description</h2>
<h3>1 – Bin2Hex Method</h3>
<p>The bin2hex function converts the binary representation data to hexadecimal representation. The bin2hex function returns a text string encoding ASCII that contains hexadecimal representation of the string parameter.&nbsp;</p>
<p>It has " The String " as parameter and it returns the hexadecimal representation of the entered text string.&nbsp;</p>
<p>To use the Bin2Hex method you need to pass the string as parameter</p>
<p><code>bin2hex($string)</code></p>
<p>In this example I will convert a string " PHP is the best ! " to the Hexadecimal representation using " Bin2Hex " method</p>
<p><code>$str = "PHP is the best !"; &nbsp;&nbsp;&nbsp;</code></p>
<p><code>$b2x = bin2hex($str); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code></p>
<p><code>echo "PHP is the best ! in HEX : " . $b2x;&nbsp;</code></p>
<p>I created a variable " b2x " to contain the returning value from the method and I passed the string as parameter , this is the result</p>
<p><img src="https://cdn.steemitimages.com/DQmcNrytYRVNBmcDybCVFcE6NqY2jQ7U2u4LXneaQhfrY7E/capture-20181223-231442.png" width="876" height="207"/></p>
<h3>2 – Count_Chars Method</h3>
<p>The count_chars function returns information about the characters in the text string. The function returns the number of iterations for each byte-value from the value 0 to 255 in a text string in different ways.</p>
<p>It has the string as parameter and it returns 4 results depending on the number that you give as parameter.&nbsp;</p>
<p>To use the count_chars method you must pass the string and the num as parameters</p>
<p><code>count_chars($string, num)</code></p>
<p>The method returns 4 results depending to the num passed as parameter , for example if the " num " equals to 1 it will return an array with ASCII code of values exist in the string passed as parameter, also if the " num " equals to 3 it will return a string with all the letters used in the string .</p>
<p><img src="https://cdn.steemitimages.com/DQmRjg6ygh2doDFzqxNQVFwMm9gENP117yarM83PZWe3CWE/capture-20181223-232005.png" width="402" height="429"/></p>
<p><img src="https://cdn.steemitimages.com/DQmeo1agBCYQXuSEqnymC6n2qWcS5f38fxtmY7ezTLpezcM/capture-20181223-232023.png" width="1348" height="273"/></p>
<h3>3 – Explode Method</h3>
<p>The explode function divides a text string into sections and returns it as an array. The explode function returns an array of text strings. Each text string is a segmentation of the total text string by dividing it at the delimiter string.&nbsp;</p>
<p>It has 3 parameters :&nbsp;</p>
<ul>
  <li>The first is the delimiter : The string selector, which is the type in which the text string will be divided.&nbsp;</li>
  <li>The second is string The entered text string to segment.&nbsp;</li>
  <li>The third parameter is limit : If the parameter value is positive, the returned array will contain elements with a limit number, with the last element in the array containing the rest of the text string. If the parameter value is negative, the returned array will contain all text string characters except another -limit element. &nbsp;</li>
</ul>
<p>To use the explode method you pass the delimiter and the string as parameters</p>
<p><code>explode(delimiter,$string)</code></p>
<p>I will use the same string " PHP is the best ! " as parameter to the explode method , it will return an indexed array starts from 0 to the number of the last element.</p>
<p><code>&nbsp;print_r(explode(" ", $str));&nbsp;</code></p>
<p>The delimiter is the space , the explode method will cut the element before the space and add it to the array , finally it will return the indexed array</p>
<p><img src="https://cdn.steemitimages.com/DQmX6z1cc7Y8DmX2jtSQFU3QQ5pnwNejHw3gV3RRbqTSh33/capture-20181223-232620.png" width="473" height="297"/></p>
<h3>4 – Hex2Bin Method&nbsp;</h3>
<p>The hex2bin function decodes the hexadecimal encoding of the binary representation strings. The hex2bin function does not convert the hexadecimal representation of numbers to binary representation, but uses the base_convert () function to perform such a transformation.&nbsp;</p>
<p>It has " the data " as parameter and it returns the binary representation of the entered data, or the FALSE value in case of failure.</p>
<p>The hex2bin function causes the error E_WARNING if the length of the text string is odd or has a hexadecimal representation. &nbsp;</p>
<p>To use the Hex2Bin method you must pass the string as parameter</p>
<p><code>hex2bin($string)</code></p>
<p>I will use the " b2x " variable that I have created in the previous example to convert it from the hexadecimal representation to the binary</p>
<p><code>echo hex2bin($b2x);&nbsp;</code></p>
<p>The function will return a binary data from the hexadecimal representation and this is the result</p>
<p><img src="https://cdn.steemitimages.com/DQmZyDvPgz6NxhREyoEd6PvLh7XUW2bYmBL22KrsgCpy5he/capture-20181223-233238.png" width="385" height="103"/></p>
<h2>Video Tutorial&nbsp;</h2>
<p>&nbsp;https://www.youtube.com/watch?v=iJtyRloB-wk&amp;feature=youtu.be</p>
<h2>Curriculum</h2>
<ul>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-01-indexed-arrays-associative-arrays-and-multidimensional-arrays">PHP Tutorial #01 Indexed Arrays, Associative Arrays and Multidimensional Arrays</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-02-array-methods-sort-rsort-ksort-krsort-arrayreverse-and-shuffle">PHP Tutorial #02 Array Methods (Sort, Rsort, Ksort, Krsort , Array_Reverse And Shuffle)</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/5jhula-php-tutorial-03-array-methods-search-methods-addition-methods-and-the-remove-methods">PHP Tutorial #03 Array Methods ( Search Methods , Addition Methods and the Remove Methods)</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-04-array-methods-arraysum-arrayrand-arraycolumn-and-arrayunique">PHP Tutorial #04 Array Methods (Array_Sum, Array_Rand, Array_Column and Array_Unique)</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-05-array-methods-arraychunk-arraycombine-arraycountvalues-and-arrayproduct">PHP Tutorial #05 Array Methods (Array_Chunk, Array_Combine, Array_Count_Values and Array_Product)</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-06-array-methods-arrayfillkeys-arrayfill-arrayflip-and-arrayfilter">PHP Tutorial #06 &nbsp;Array Methods (Array_Fill_Keys,Array_Fill, Array_Flip and Array_Filter)</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-07-array-methods-arraykeys-arraymap-arraymerge-and-arraypad">PHP Tutorial #07 Array Methods ( Array_Keys, Array_Map, Array_Merge and Array_Pad )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-08-array-methods-arrayreplace-arrayvalues-arrayslice-and-arrayintersect">PHP Tutorial #08 Array Methods ( Array_Replace, Array_Values, Array_Slice and Array_Intersect )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-09-array-methods-arraywalk-current-next-prev-end-and-reset">PHP Tutorial #09 Array Methods (Array_Walk, Current, Next, Prev, End and Reset )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-10-array-methods-arraydiffkey-arraydiff-arrayintersectkey-and-arraychangekeycase">PHP Tutorial #10 Array Methods (Array_Diff_Key, Array_Diff, Array_Intersect_Key and Array_Change_Key_Case )</a></li>
</ul>
<h2>Proof of Work Done&nbsp;</h2>
<p>https://github.com/alexendre-maxim/PHP-Tutorial/blob/master/str2.php</p>
</html>
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 44 others
properties (23)
authoralexendre-maxim
permlinkphp-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin
categoryutopian-io
json_metadata{"tags":["utopian-io","video-tutorials","video","programming"],"image":["https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg","https://cdn.steemitimages.com/DQmcNrytYRVNBmcDybCVFcE6NqY2jQ7U2u4LXneaQhfrY7E/capture-20181223-231442.png","https://cdn.steemitimages.com/DQmRjg6ygh2doDFzqxNQVFwMm9gENP117yarM83PZWe3CWE/capture-20181223-232005.png","https://cdn.steemitimages.com/DQmeo1agBCYQXuSEqnymC6n2qWcS5f38fxtmY7ezTLpezcM/capture-20181223-232023.png","https://cdn.steemitimages.com/DQmX6z1cc7Y8DmX2jtSQFU3QQ5pnwNejHw3gV3RRbqTSh33/capture-20181223-232620.png","https://cdn.steemitimages.com/DQmZyDvPgz6NxhREyoEd6PvLh7XUW2bYmBL22KrsgCpy5he/capture-20181223-233238.png","https://img.youtube.com/vi/iJtyRloB-wk/0.jpg"],"links":["https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg","https://github.com/php/php-src","https://www.youtube.com/watch?v=iJtyRloB-wk&feature=youtu.be","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-01-indexed-arrays-associative-arrays-and-multidimensional-arrays","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-02-array-methods-sort-rsort-ksort-krsort-arrayreverse-and-shuffle","https://steemit.com/utopian-io/@alexendre-maxim/5jhula-php-tutorial-03-array-methods-search-methods-addition-methods-and-the-remove-methods","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-04-array-methods-arraysum-arrayrand-arraycolumn-and-arrayunique","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-05-array-methods-arraychunk-arraycombine-arraycountvalues-and-arrayproduct","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-06-array-methods-arrayfillkeys-arrayfill-arrayflip-and-arrayfilter","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-07-array-methods-arraykeys-arraymap-arraymerge-and-arraypad","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-08-array-methods-arrayreplace-arrayvalues-arrayslice-and-arrayintersect","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-09-array-methods-arraywalk-current-next-prev-end-and-reset","https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-10-array-methods-arraydiffkey-arraydiff-arrayintersectkey-and-arraychangekeycase","https://github.com/alexendre-maxim/PHP-Tutorial/blob/master/str2.php"],"app":"steemit/0.1","format":"html"}
created2018-12-23 22:38:09
last_update2018-12-23 22:38:09
depth0
children7
last_payout2018-12-30 22:38:09
cashout_time1969-12-31 23:59:59
total_payout_value13.797 HBD
curator_payout_value4.367 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8,821
author_reputation18,071,828,077,109
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,289,868
net_rshares32,488,412,179,254
author_curate_reward""
vote details (108)
@rosatravels ·
$12.69
Hi @alexendre-maxim

Thank you for your contribution to the video tutorial.

I am very pleased with the improvement you have made in the tutorial.  The presentation is getting better and also you have made the 'fonts' to good sizes for learners to follow easily.

I also see you varying your tones in your lecturing speech. This is important because learners can pick up the emphasis and follow your lessons easier.

I am sure as you continue on to develop better outlines and structures,  your tutorials will continually improve.

I can see that you have taken the suggestions given to you.  Thank you for implementing them.

You will be happy to see the higher score this time.  Merry Christmas.

Have a happy holiday!

Rosa

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/9/1-2-2-3-2-2-2-2-3-).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , , ,
properties (23)
authorrosatravels
permlinkre-alexendre-maxim-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181224t155618090z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["alexendre-maxim"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/9/1-2-2-3-2-2-2-2-3-","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-12-24 15:56:21
last_update2018-12-24 15:56:21
depth1
children2
last_payout2018-12-31 15:56:21
cashout_time1969-12-31 23:59:59
total_payout_value9.580 HBD
curator_payout_value3.109 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,228
author_reputation422,827,447,688,168
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,325,172
net_rshares22,607,784,364,204
author_curate_reward""
vote details (15)
@alexendre-maxim ·
@rosatravels Thank you very much and I am really happy that I provide content that helps the users and followers to understand this language.
properties (22)
authoralexendre-maxim
permlinkre-rosatravels-re-alexendre-maxim-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181228t135036001z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["rosatravels"],"app":"steemit/0.1"}
created2018-12-28 13:50:36
last_update2018-12-28 13:50:36
depth2
children0
last_payout2019-01-04 13:50:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length141
author_reputation18,071,828,077,109
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,494,813
net_rshares0
@utopian-io ·
Thank you for your review, @rosatravels! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-alexendre-maxim-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181224t155618090z-20181226t224142z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-26 22:41:42
last_update2018-12-26 22:41:42
depth2
children0
last_payout2019-01-02 22:41:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length63
author_reputation152,955,367,999,756
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,425,079
net_rshares0
@steem-ua ·
#### Hi @alexendre-maxim!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181224t170334z
categoryutopian-io
json_metadata"{"app": "beem/0.20.14"}"
created2018-12-24 17:03:36
last_update2018-12-24 17:03:36
depth1
children1
last_payout2018-12-31 17:03:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length294
author_reputation23,214,230,978,060
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,328,151
net_rshares0
@alexendre-maxim ·
Thank you
properties (22)
authoralexendre-maxim
permlinkre-steem-ua-re-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181224t170334z-20181228t135211836z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-12-28 13:52:12
last_update2018-12-28 13:52:12
depth2
children0
last_payout2019-01-04 13:52:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation18,071,828,077,109
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,494,863
net_rshares0
@utopian-io ·
Hey, @alexendre-maxim!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181225t032152z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-25 03:21:54
last_update2018-12-25 03:21:54
depth1
children1
last_payout2019-01-01 03:21:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length597
author_reputation152,955,367,999,756
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,345,551
net_rshares0
@alexendre-maxim ·
Thank you
properties (22)
authoralexendre-maxim
permlinkre-utopian-io-re-php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin-20181225t032152z-20181228t135230843z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-12-28 13:52:30
last_update2018-12-28 13:52:30
depth2
children0
last_payout2019-01-04 13:52:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation18,071,828,077,109
root_title"PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,494,875
net_rshares0