Jump to content

Search the Community

Showing results for tags 'keys'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 4 results

  1. Hi, simply put; I am having a very difficult time trying to find a way I can Match (partial?) strings, comparing to 2 arrays (the matches have different [Keys].) for example: $abs="Bob Rob Sue"; $abt="sometext Bob1:2 moretext Sue3:4 othertext Rob5:6 etc"; how can I put into code, when "Bob1:2" is used, it finds a match of "Bob", and assigns the complete string of "Bob1:2" ? The course I have been trying I get Bob, Rob, and Sue.. but the #numbers# are in the wrong place. ie; it will result with "Sue5:6" I understand its a [key] issue, using array_intersect along with some explodes/implodes has helped get me this far.. but i am stumped. Someway of matching the two arrays coreectly (or keys) would be what i need to figure out. Heres is what i have now: Thank you for any help, at all. cheers. <?php $abs="Bob Rob Sue"; $abby="sometext Bob1:2 is Sue3:4 where Rob2:1 etc"; $nums = preg_replace('/[a-zA-Z]/', ' ', $abby); $lets = preg_replace('/[0-9]:?[^0-9]/', ' ', $abby); //$lets1=array_intersect($abs, $lets); $absArr = explode(' ', $abs); $abbyArr = explode(' ', $lets); $letsx=array_intersect($absArr, $abbyArr); //echo $letsx[0] . "</br>"; //############################################# $nums1='/(\d+\:\d+)/s'; preg_match_all($nums1, $nums, $nums2); foreach($nums2 as $numsx){ } $abi0="$letsx[0]+$numsx[0]"; $abi1="$letsx[1]+$numsx[1]"; $abi2="$letsx[2]+$numsx[2]"; $answer=$abi0."</br>".$abi1."</br>".$abi2."</br>"; echo $answer; ?> current results: Bob+1:2 Rob+3:4 Sue+2:1 My desire is that it would Result in: Bob+1:2 Sue+3:4 Rob+2:1 The #nums are obviously correct. but the #letters (words/names) obviously are not the same "[key]". I hope that this is doable.. Thanks in advance.
  2. So I have a database that is structured like this: https://imgur.com/a/DdyTqiE Sample data: https://imgur.com/a/kYwmuO1 For each appointment, a student can have multiple categories, such as 'Academic Probation, Re-Admit' etc... I would like to loop through this table, and get a count of how many were 'is_no_show' and 'is_cancelled' per (unique) category with respect to 'scheduled_student_services.' For example, in the sample data, we see that the first appointment has 4 categories (Academic Probation, Entering Cohort Year 20051, First Generation, and Re-Admit'). Now one of these categories - Academic Probation matches up with what they were scheduled for - '1st Term Probation Advising'. And they cancelled this appointment, so we want the count of cancellations under Academic Probation to go up by 1. How would I approach this? I know I probably need to do two loops but I'm not sure the PHP syntax for this. Any suggestions or tips would be helpful. Thank you for your time!
  3. The website I am working on is a HRIS project for a popular fast food franchise chain. The login for one restaurant allows one user to modify all actions for all restaurants owned by the same franchisee. These are organized by multiple databases calling the same id's. Below is the code used for selecting all restaurants where the same franchise id is used as the restaurant login. $result = mysql_query("SELECT id, name FROM restaurants WHERE franchise = $_SESSION[sESS_RESTAURANT_FRANCHISE]"); $_SESSION['franchise_arr'] = array(); while($row = mysql_fetch_array($result)){ $_SESSION['franchise_arr'][$row['id']] = $row['name']; } So lets say for one login the SESSION array is populated like this: $_SESSION[sESS_RESTAURANT_FRANCHISE][1] = "Restaurant One"; $_SESSION[sESS_RESTAURANT_FRANCHISE][15] = "Restaurant Two"; $_SESSION[sESS_RESTAURANT_FRANCHISE][29] = "Restaurant Three"; I need a way to check to see if the KEY value is in an array as oppose to the value itself. For example I have: if (!in_array($rest, $_SESSION['franchise_arr'])){ $rest = $_SESSION['SESS_RESTAURANT_ID']; } However that checks for the values "Restaurant One", "Restaurant Two", "Restaurant Three". Where I would like it to look for "1", "15", or "29". I hope someone understands what I mean :\ I've been strugging with this for quite a while.
  4. is it possible to store the keys of an array in to variables? currently my code looks like this: function getanswers() { $sql = mysql_query("select answer FROM answers WHERE question_ID= 1 "); while($row =mysql_fetch_row($sql)) { //print_r (array_keys($row)); $ans1 = $row['0']; $ans2 = $row; $ans3 = $row; $ans4 = $row; echo $ans1 . $ans2. $ans3. $ans4 ; } } and all I get are undefined offset notices what am i doing wrong? I'd appreciate any advice the output looks like this: The ‘Sea Swallow’ is an alternative name for which bird? Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 29 Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 30 Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 31 Seagull Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 29 Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 30 Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 31 Penguin Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 29 Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 30 Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 31 Tern Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 29 Notice: Undefined offset: 2 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 30 Notice: Undefined offset: 3 in /Applications/MAMP/htdocs/Quiz/newfile.php on line 31 Cormorant Just in case it helps when I call the array keys they show this: Array ( [0] => 0 )Array ( [0] => 0 )Array ( [0] => 0 )Array ( [0] => 0 ) Thanks in advance to anyone who can help!
  • 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.