PHP Arrays and Strings Interface

Asked

Viewed 99 times

1

Situation

I have a page in PHP that does CNPJ searches and returns the values, but as it is without any formatting the results appear in forms of ARRAY and STRINGS.

Example

    array(23) { [0]=> string(18) "XX.XXX.XXX/XXXX-XX" [1]=> string(10) 
    "XX/XX/XXXX" [2]=> string(58) "EMPRESA XXXXXXXX" [3]=> string(10) 
    "FANTASIA" [4]=> string(90) "DESCRIÇÃO" [5]=> array(2) { [0]=> 
    string(67) "4X.5X-2-0X - XXXXXXXXXX SERVIÇOS " [1]=> string(80) 
    "XX.11-X-00 - Atuação XXXXXXXX" } [6]=> string(68) "230-5 - 
    EMPRESA INDIVIDUAL DE RESP.LIMITADA (DE NATUREZA EMPRESARIA)" 
    [7]=> string(37) "R XXXXXXXXXX (JD XX)" [8]=> string(2) "55" 
    [9]=> string(0) "" [10]=> string(10) "09.XX0-XXX" [11]=> string(15) 
    "XXX BAIRRO" [12]=> string(21) "XXX XXXX XX XXX" [13]=> string(2) 
    "XX" [14]=> string(26) "[email protected]" [15]=> string(14) 
    "(1x) XXXX-XXXX" [16]=> string(5) "*****" [17]=> string(5) "ATIVA" 
    [18]=> string(10) "XX/03/XXXX" [19]=> string(0) "" [20]=> string(8)
     "********" [21]=> string(8) "********" ["status"]=> string(2) "OK" }

What exactly do you want?

I’m not looking for anything chewed on, I just want a direction, where to start. More specifically I would like to know how to specify for a certain space to call a certain string, for example: a text box that inside it will have the string 8.

Abstract

Allocate Array and String at a specified location.

I hope you understand, if I can get a better idea of how to explain, I edit the question.

  • 1

    I didn’t understand anything. I could try to explain again?

  • 1

    What you have there in the example is no more than an array with size 23. For example, [0]=> string(18) "XX.XXX.XXX/XXXX-XX", at position 0 you have a string with size 18 which is "XX.XXX.XXX/XXXX-XX" and so on... array[0] = "XX.XXX.XXX/XXXX-XX"

  • How about asking the question the code you currently use to format the output? It may help make your need more clear.

1 answer

3


I think you’re confusing that "string(n)" that appears shows only the size of the characters that are within each index of the array.

If I understand correctly, I believe you are wanting to show a single index of the array separately. If this is the case with the following distributed array like this:

$array = array(
    [0] => "a",
    [1] => "b",
    [2] => "c",
    [3] => "d"
);

or so:

$array = array([0] => "a", [1] => "b", [2] => "c", [3] => "d");

Just call the Dice you want:

//o resultado seria "b"
echo $array[1];

I hope I’ve helped;

Att;

  • that’s right, I’m sorry for the bad explanation, but you interpreted it well, exactly that. I thank @fleuquer-file

  • 1

    No problem, I’ve been through the same situation... = P. Any doubt I can help I’m available.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.