Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: A few questions

  1. #1
    New Coder
    Join Date
    Jun 2011
    Location
    Bristol, United Kingdom
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    A few questions

    Question 1 :
    how can i check no code is being implemented to my database?
    Question 2 :
    How can i take an array and split it e.g.

    PHP Code:
    $array = array('1' => '10''2' => '20');
    foreach(
    $array){
      echo 
    $array['name'].' : '.$array['equals'].'<br />';

    should show :
    1 : 10
    2 : 20

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,211
    Thanks
    23
    Thanked 605 Times in 604 Posts
    Either this:
    PHP Code:
    $array = array('name' => '10''equals' => '20');
    echo 
    $array['name'].' : '.$array['equals'].'<br />'
    Or this
    PHP Code:
    $array = array('1' => '10''2' => '20');
    echo 
    $array['1'].' : '.$array['2'].'<br />'
    Your foreach is wrong do this:
    PHP Code:
    $array = array('1' => '10''2' => '20');
    foreach (
    $array as $key => $value)
      echo 
    $key.' : '.$value.'<br />'
    Your 2nd answer: Use array_slice here:http://php.net/manual/en/function.array-slice.php

    1st question is hard to answer. I use phpMyAdmin, MyWebSQL, or MySQLWorkbench and just look at it.
    Last edited by sunfighter; 03-27-2013 at 02:34 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    RobertWoges (03-27-2013)

  • #3
    New Coder
    Join Date
    Jan 2013
    Posts
    71
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by sunfighter View Post
    Either this:
    PHP Code:
    $array = array('name' => '10''equals' => '20');
    echo 
    $array['name'].' : '.$array['equals'].'<br />'
    Or this
    PHP Code:
    $array = array('1' => '10''2' => '20');
    echo 
    $array['1'].' : '.$array['2'].'<br />'
    Your foreach is wrong do this:
    PHP Code:
    $array = array('1' => '10''2' => '20');
    foreach (
    $array as $key => $value)
      echo 
    $key.' : '.$value.'<br />'
    Your 2nd answer: Use array_slice here:http://php.net/manual/en/function.array-slice.php

    1st question is hard to answer. I use phpMyAdmin, MyWebSQL, or MySQLWorkbench and just look at it.

    Yes,He has explained so beautifully.I liked the way he explained.Please try this.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •