Search the Community
Showing results for tags 'strings'.
Hi Larry, I hope all is well with you. I have what I thought was a simple problem with a simple solution. 😄🤣 I have in a mysql database a table with data so: 12345/98765 (they are co-ordinates). I need to subtract a number from the left number and a different number from the right number, and then put them back. Thus I need to assign the left hand number to a variable, and the right hand number to another variable. Then I can do the subtraction and replace the co-ordinates. The two numbers aren't necessarily always the same number of digits. I have thought about str_replace, ltrim, rtrim, strpos etc. but none of them cut the mustard. I'd rather do it in php that use LEFT() and RIGHT() in MySql. Any ideas? I have now wasted a whole afternoon on this. 🙄 Max
Hi Larry, First of all, thanks for the book. It's being surprisingly easy to follow. I'm currently going through chapter 07 (arrays) and I was doing the excercise in "Transforming Between Strings and Array", I first created my list.html file and then on the list.php, this is what I wrote (HTML omitted): <?php //Get text from form $sorted_words = explode(' ',$_POST['words']); //Sort values sort($sorted_words); //Turn array back into a string $string_words = implode("<br />",$sorted_words); //Prints string print "<p>Alphabetized version of your text: <br />$string_words</p>"; ?> Everything working fine. However, the moment I add something else as separator: $sorted_words = explode(',',$_POST['words']); It prints out the phrase exactly as entered in the form, nothing seems to happen, no errors either. Where is the problem? PS: I've seen you are currently working on the 5th edition of "PHP and MySQL for Dynamic Web Sites". Any updates of how is it going? Planning to buy it as song as it gets published Many thanks in advance, Luis.