Category : substr

I have a problem with the strpos & substr function, thank you for your help: $temp = "U:hhp|E:[email protected],P:h123"; $find_or = strpos($temp,"|"); $find_and = strpos($temp,","); $find_user = substr($temp,2,$find_or-2); $find_email = substr($temp,$find_or+3,$find_and); $find_passeord = substr($temp,$find_and+3,strlen($temp)); echo("$find_user+$find_email+$find_passeord<br/>"); /************************************/ Why is the output like this ?? [email protected],P:h123 +h123 but i want this: [email protected],h123 Sourc..

Read more

For grabbing the first letter of a string i use substr $string = "John doe"; echo substr($string,0,1); // output: J But this does not work when the string is, per example in russian of with accented letter $string = "Марина Матвиенко"; echo substr($string,0,1); // output: nothing $string = "Éduard Rousseaux"; echo substr($string,0,1); // output: nothing ..

Read more

Here is my code: $content = apply_filters(‘the_content’, get_the_content()); $first_slice = html_entity_decode( wp_trim_words( htmlentities( $content ),100, ” ) ); $second_slice = html_entity_decode( substr($content,strlen($first_slice),strlen($content))); echo ‘<div class="non-paywall">’. $first_slice .'</div>’; echo ‘<div class="paywall">’. $second_slice .'</div>’; Second slice is starting at wrong point and repeating few words that exist in first slice. How do I fix this? Source: Ask ..

Read more

I have multiple views that has a common @section that will be displayed in a layout file. And i have to limit the number of characters that @yield returns. // layout.blade.php … <meta property="og:title" content="@yield(‘og_title’, ‘Default Value’)" /> … // sample.blade.php … @section(‘og_title’, $page->og_title) … Although the sample is simple enough to understand, each og_title ..

Read more

<?php $conn1 = new MySqli(‘localhost’,’root’,”,’test’); $data = "Hubert Blaine Wolfeschlegel Steinhausenbergerdorff Sr."; $namelength = strlen($data); $a = 20; echo"<br>".$data; #first name $a = 20; if($namelength <= $a) { echo"<br>".$firstname = substr($data ,0,$a); } else if ($namelength >= $a) { $a = 20; while(substr($data ,$a, 1) != " ") { $a–; } echo"<br>".$firstname = substr($data ,0, ..

Read more