Jump to content

loudog

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

loudog's Achievements

Member

Member (2/5)

0

Reputation

  1. hey guy's, Im trying to compare two array's to see it they have any common variables(i think that's what they are called) if they do have the function print out the common variable if they don't have the function print something saying they don't. Anyway, Im having trouble comparing the actual arrays this is what i have so far. thanks in advance. <?php function dz_compare($a,$b){ $v=$a[$key]; $v1=$b foreach($a as $key=>$value) foreach($b as $key =>$value) if($v1) } } $a=array(1=>"dog",2=>"cat",3=>"horse"); $b=array(1=>"horse",2=>"mouse",3=>"fish"); ?>
  2. that's a good idea but wouldn't that be cheating?? Im a newbie and i have a list of per set functions that i want to rewrite. Im doing this cuz it will help me better understand and know that tool's i have to my disposal. Is there any other way??
  3. hey guy's. Im trying to write my own function for array_udiff_assoc. So i need to compare two arrays in the same function and i was thinking that the best way would be to go element by element in other words compare each individual key to each other. for example compare key1 or array to key one of array2. My question is how can i compare each key of the array to each other?? Does it make sense?? $a1=array(1=>"Dog",2=>"Cat",3=>"Horse"); $a2=array(1=>"Cat",2=>"Horse",3=>"Dog");
  4. Its the array_flip is done and Thank you guys for helping me.......I love this site.
  5. Alright guy's, I think just got me into a situation here. I was able to flip them around with out using the array_flip function but here is the situation. i get both array's the regular and the flip one now i just don't know how to get rid of the regular one and just keep the array that i flip. :-\ Here is the code. thanks in advance. <?php function dz_flip($temp){ /*$arr=''; for($i=0; $i>$temp; $i--){ $arr.=$temp[$i]; }*/ foreach($temp as $key => $value){ $temp[$value]=$key; } return $temp; The output is this Array ( [horse] => 1 [cat] => 2 [dog] => 3 [1] => horse [2] => cat [3] => dog ) } $temp=array("horse"=>1,"cat"=>2,"dog"=>3); print_r (dz_flip($temp)); //print_r(array_flip($temp)); ?>
  6. I need to do this cuz is part of assignment. So im going to try my darnest to do it if not i'll be back here begging for help. :'(
  7. hey guy's Im having trouble with writing my own function for array_flip. What im trying to get the same output that the original array_flip does but im not sure if im on the right direction. Here is what i got so far. Plz keep in mind im a newbie. thanks in advance. <?php function dz_flip($trans){ $temp=array("a"=>0,"b"=>1,"c"=>2); $arr=''; for($i=-1; $i<$temp; $i--){ $arr.=$temp[$i]; $temp=array_flip($trans); } return $temp; }
  8. That is the hardest thing about all this, i am still not very familiar with loops and functions. so what is the best way to learn how to use them and when to use them?? btw that last comment u made gizmola really took some weight off me. I was trying to feel like i was biting more than i could chew and was going to choke to death .thanks bro for reminding me that this is learning process.
  9. That's what im talking about gizmola. what you just did above in the quote section and how u just wrote that function even tho it was just of the top of your head and you are not sure it works That's what my problem is when i start the coding process. i get stuck i don't know if i should use the if, switch, or foreach statements like you did. how did u decide what statements to use? what process do take to know what kind of statements ur going to to be using when u begin the code or function?
  10. that's the problem that idk what statement should i use. should i use the if,while, or foreach. im lost and the teacher won't except a reuse of the php net example even if i change the name or the variable. am i missing the point?? this is the php manual example <?php $input = "Alien"; echo str_pad($input, 10); // produces "Alien " echo str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien" echo str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___" echo str_pad($input, 6 , "___"); // produces "Alien_" ?>
  11. The funny thing is that in the internet course i took for php that was the project. we did the following things of course u still have to valid it them with php or javascript and inserting the values into my sql. If you don't know what to put for info you could always copy the reg and log in page from facebook. 1 registration page. 2 log in page 3 profile page.(In that page is where you upload you're pics) 4 add and delete friends page 5 changing ur password page.
  12. its not so much the the function but what type of argument should i use that gets me confuse in this assignment. i don't know if i use and if statement,while loop,or , foreach. I look at the examples the they have in php manaul and it just makes me feel even more lost :-\
  13. hey guys, I just got an assignment which im having alot of trouble with and i was hoping that you guy's could help me. The assignment is that i must write my own functions. I've read the php manual and yes i do understand how to write a function but im not very good at writing my own this is my first time and what makes it worst is that i can't copy someone else function i have to write my own. In this assignment you will have to rewrite some of the built-in functions. For example: If I ask you rewrite the function strrev() (strrev reverses a given string),you can do something like this: function dan_strrev($input) { $i = 0; $myLen = 0; while (true) { if (isset($input[$i])) { $myLen = $myLen + 1; $i = $i + 1; } else { break; } } $temp = ''; for ($i = $myLen - 1; $i >= 0; $i--) { $temp = $temp.$input[$i]; } return $temp; } echo dan_strrev('Hello'); echo strrev('Hello'); So, you can see that both the built-in function strrev() as well as the one we wrote (dan_strrev()) gives the same output. Please do the same for the following built-in functions: 1).str_pad — Pad a string to a certain length with another string 2).str_split — Convert a string to an array 3).str_repeat — Repeat a string 4).array_combine — Creates an array by using one array for keys and another for its values 5).array_flip — Exchanges all keys with their associated values in an array 6).array_pop — Pop the element off the end of array 7).array_udiff_assoc — Computes the difference of arrays with additional index check, compares data by a callback function .array_walk — Apply a user function to every member of an array 9).array_uintersect — Computes the intersection of arrays, compares data by a callback function 10).usort — Sort an array by values using a user-defined comparison function 11).array_flip — Exchanges all keys with their associated values in an array 12).ksort — Sort an array by key 13).in_array — Checks if a value exists in an array 14).array_search — Searches the array for a given value and returns the corresponding key if successful 15).array_merge — Merge one or more arrays If you want to know how these functions,please take a look at the php manual/documentation on php.net. Email me if you have not understood anything that I have explained so far. I am not setting a deadline but it will be good if you can complete this in the next 2 weeks
  14. wow.. simple answers like that make me feel so dumb for asking questions like that .lol I guess that's the process you go thru to learn valuable skill in life. Like they once told me your not nosy you will never learn.lol ps....thanks to everyone in advance for having such patience with noob like me.
  15. Hey guy's I want you to write custom php functions which behaves like the built-in ones. What is the best way to learn how to write you're own functions??
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.