obama_san Posted November 22, 2008 Share Posted November 22, 2008 Hi guys, i have 2 questions that i hope someone will help me on. Because its killing me, i can't solve it. 1) Write a function that will convert an array of lower case strings passed by reference into an array of upper case strings e.g function convert(&$array_strings){ //insert code } I tried this: function convert(&$array_strings) { $array_strings="hello this is php coding in lower case to upper case"; $higher=strtoupper($array_strings); print("$higher"); } 2)Using regular expressions generate a function that will check if a filename stored in a string is of the correct format. The function should return a Boolean result. Any 1 upper case letter, followed by 3 lowercase letters, followed by any digit, followed by a .php or .PHP file eg. Gone8.php I tried this: function regular_expressions($boolean) { if(preg_match("/[A-Z]{1}[a-z]{3}[0-9][.]p[Hh]p/","Gone8.php")) { return 1; if ($boolean == 1) { print("true<br/>"); } return false; } Extra: what happens if you try "Gone8.phpProblem" Does it return true or false? Can anyone fix the problem if there is one?" --->Can anyone explain the answer and rationale behind it to me ? Many thanks! Quote Link to comment https://forums.phpfreaks.com/topic/133755-any-help-on-this/ Share on other sites More sharing options...
xtopolis Posted November 22, 2008 Share Posted November 22, 2008 I'm pretty sure we don't answer HW problems here.. but I may be mistaken. Quote Link to comment https://forums.phpfreaks.com/topic/133755-any-help-on-this/#findComment-696059 Share on other sites More sharing options...
zenag Posted November 22, 2008 Share Posted November 22, 2008 anyway.... try to solve pretty small things by yourself, that may teach u a lot... function convert(&$array_strings) { $higher=strtoupper($array_strings); print($higher); }$array_strings="hello this is php coding in lower case to upper case"; convert($array_strings); 2. function regular_expressions($boolean) { if(!preg_match("/[A-Z]{1}[a-z]{3}[0-9][.]p[Hh]p/",$boolean)) { return false; } else { print("true<br/>"); } } $qqq="Gone8.phpProblem" ; regular_expressions($qqq); Quote Link to comment https://forums.phpfreaks.com/topic/133755-any-help-on-this/#findComment-696063 Share on other sites More sharing options...
Mark Baker Posted November 22, 2008 Share Posted November 22, 2008 <?php $stringArray = array( 'Lorem', 'ipsum', 'dolor', 'sit', 'amet' ); echo '<pre>'; print_r($stringArray); echo '</pre>'; $stringArray = array_map('strtoupper',$stringArray); echo '<pre>'; print_r($stringArray); echo '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/133755-any-help-on-this/#findComment-696120 Share on other sites More sharing options...
.josh Posted November 22, 2008 Share Posted November 22, 2008 I'm pretty sure we don't answer HW problems here.. but I may be mistaken. We recently decided it's not our duty to be the little angel sitting on people's shoulder. If someone wants to try and get someone to do their homework for them in a class that is probably most likely voluntary in the first place, that's their prerogative. And if someone wants to come along and "help" the guy (I do use quotes because frankly, I do not think they are helping him at all), that's on them, as well. Anyways, point is, we're not babysitters or parents. We think it's retarded and stupid for someone to voluntarily take a class only to turn around and ask for other people to do the work, and even more retarded and stupid when people actually help them, but hey, that's the double edged sword of freedom of choice. Quote Link to comment https://forums.phpfreaks.com/topic/133755-any-help-on-this/#findComment-696166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.